Hy all! i have some Dataframes that look look like this
FSvalue
Season
1966-1967 288.0
1967-1968 129.0
1968-1969 384.0
1969-1970 507.0
1970-1971 236.0
FSvalue
Season
1965-1966 384.000
1966-1967 496.999
1967-1968 197.000
1968-1969 382.000
1969-1970 458.000
Now i want to combine the Frames, Season should stay in first place and FSvalue should be added from the other frames to one big frame. The problem is, that they dont start with the same season.
I want the values from the second frame to stand at the correct position in the new combined frame. So the Final Frame should have 1 column with Season and 4 columns with the values(i have 4 frames in total), but at the right Row depending on the season
my code looks like this, but x4 for all files:
df_a = pd.read_csv('xxxFreshSnowperSeason.csv', delimiter=",", dtype = {'Season': str, 'FSvalue': float}) df_a.set_index('Season', inplace=True)
CodePudding user response:
Use concat
with aggregate sum
:
df = pd.concat([df_a, df_b, df_c, df_d], axis=1).groupby(level=0).sum()