A sample dataset is structured as follows
- Home_HeatSensor_AA.CSV
- Office_HeatSensor_BB.CSV
- Ship_ElevationSensor_XXYY.CSV
AA.CSV has the following columns, with a sample row
Time AA AB BB Site Type
0 1:00 5 4 5 Home Heat
BB.CSV is formatted similarly
Time AA AB BB Site Type
0 1:00 6 2 4 Office Heat
However, XXYY.CSV has a much different format
Time XX XY YY Site Type
0 1:00 1.332 12.1123 4.212 Ship Elevation
I need to join these three CSV files into a master CSV file formatted as follows
Time AA AB AB XX XY YY Site Type
0 1:00 5 4 4 Home Heat
0 1:00 6 2 2 Office Heat
0 1:00 1.332 12.1123 4.212 Ship Elevation
I've tried mucking about with pandas a bit but the results have been mixed. The code below will join the data but switches but the column order of time, Site, and Unit. Ideally I'd like these two to stay static, with time in the front of the order and Site and Unit staying the last two column values
for filename in filepaths:
df = pd.read_csv(filename, index_col=None, header=0, parse_dates=True,infer_datetime_format=True)
li.append(df)