This is what I have
Country Fruit grown Prod(Tonnes)
USA Apples 100
USA Oranges 50
USA Other Fruits[] 60
India Apples 200
India Oranges 50
India Other Fruits[] 50
This is what I want
Country Fruits
Apples Oranges Other Fruits
USA 100 50 60
India 200 50 50
This is what I have tried
df3 = final_df2.pivot_table('country', 'fruits')
uj5u.com熱心網友回復:
你可以試試'Piviot'
print(df.pivot(index='country', columns='Fruit grown', values='grown'))
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/513798.html
