Pandas: Unstacking One Column of a DataFrame
--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Luau
--
Chapters
00:00 Pandas: Unstacking One Column Of A Dataframe
00:59 Accepted Answer Score 4
01:14 Thank you
--
Full question
https://stackoverflow.com/questions/2155...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #pandas
#avk47
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Luau
--
Chapters
00:00 Pandas: Unstacking One Column Of A Dataframe
00:59 Accepted Answer Score 4
01:14 Thank you
--
Full question
https://stackoverflow.com/questions/2155...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #pandas
#avk47
ACCEPTED ANSWER
Score 4
If you can drop Product, Unit, and Flow then it should be as easy as
df.reset_index().pivot(columns='Country', index='Date', values='Quantity')
to give
Country AUSTRALI CANADA FINLAND TURKEY UK
Date
2002-01-31 12.2787 5.1161 3.8129 0.2542 12.2013