0

I've asked this question here: Create a new Dataframe with restructured data using lambda function

Which is a duplicate here: How to pivot a dataframe

But there are few things I just can't seem to get.

I've inserted a 'count' column on my rwy16_df DataFrame using:

rwy16_df.insert(0, 'count', rwy16_df.groupby('cloud_range').cumcount())  

To get:

enter image description here

And now I want to reshape the DataFrame to something like:

enter image description here

Having tried:

pivoted_count = pd.pivot_table(rwy16_df, values='maestro_rate', columns='cloud_range', aggfunc='count')

Which give me:

enter image description here

Tim
  • 63
  • 7

0 Answers0