Reputation: 187
suppose that we have the following DF:
Temp_max Temp_min Vent
mean 16.800000 26.366667 26.466667
std 5.202122 5.486556 8.488261
min 4.000000 11.000000 11.000000
I want to have to Convert this DF from 3*3 cell to 1*9 cell like this:
Temp_max_mean Temp_max_std Temp_max_min Temp_min_mean Temp_min_std Temp_min_min Vent_mean Vent_std Vent_min
16.800000 5.202122 4.000000 26.366667 5.486556 11.000000 26.466667 8.488261 11.000000
Is there any predifined function to do that ?
Upvotes: 0
Views: 33
Reputation: 544
You can do this like this:
df = df.unstack().to_frame().T
df.columns = ['_'.join(column) for column in df.columns]
Upvotes: 2