measure_rect_preproc.py 937 Bytes
Newer Older
Jean-Marie Lepioufle's avatar
Jean-Marie Lepioufle committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import argparse
import pandas as pd

def main():
    """
    Main pre-proc for dataset got from 'measure_rect'
    """
    parser = argparse.ArgumentParser(description="Argument parsing for data pre-proc")
    parser.add_argument("-d", help="path and filename of the dataset")
    parser.add_argument("-o", help="path and filename of the csv output")
    args = parser.parse_args()
    df = pd.read_csv(args.d,skiprows=2,header=None)
    df = df.drop_duplicates()
    df.columns=["Day","Month","Year","Hour","Minute","Second","Wday","SN","Element","Unit","Value","Lat","Lon"]
    df = df.pivot(index=['Year','Month','Day','Wday','Hour','Minute','Second','SN','Lat','Lon'],columns='Element',values=['Value'])
    dataset = df["Value"].reset_index(level=['Year','Month','Day','Wday','Hour','Minute','Second','SN','Lat','Lon'])
    dataset.to_csv(args.o)
    print("measure_rect pre-proc completed.")

if __name__ == "__main__":
    main()