I have two dataframes. Both are having the same headers as they are data from different houses. I want to concatenate them side by side based on timestamp column. Below is example of my data and my code which I am using.
df = pd.DataFrame()
for cluster in os.listdir():
os.chdir(path +"\\"+ cluster)
for H in os.listdir():
os.chdir(path +"\\"+ cluster +"\\"+H )
for file in os.listdir():
if file.endswith(".csv"):
print(file)
df1 = pd.read_csv(file)
df1 = df1.set_index('Timestamp')
df = pd.concat([df,df1], axis=1)
df.to_csv(path +"\\"+"mastersheet.csv")
My dataframe:
| Timestamp | Energy | Voltage |
|---|---|---|
| 12/02/2020 12:00:00 | 23 | 230 |
| 12/02/2020 12:15:00 | 23.5 | 234 |
and so on.
I have similar tables from various houses and I want to place them side by side with a common timestamp column. With my code, I am getting the following error:
Shape of passed values is (43395, 22), indices imply (32583, 22)
Kindly help