I have this dataframe:
date | fruit
|
2019-05-30 | apples
2019-05-30 | bananas
2020-01-12 | oranges
2020-02-14 | oranges
2020-02-14 | bananas
2020-03-20 | apples
2020-03-20 | oranges
2020-04-05 | apples
I want to reduce the date column down to its unique values, but keep all the data that appears on duplicate date rows by moving it to its own columns. Like this:
date | apples | bananas | oranges
| | |
2019-05-30 | apples | bananas |
2020-01-12 | | | oranges
2020-02-14 | | bananas | oranges
2020-03-20 | apples | | oranges
2020-04-05 | apples | |
I can think of a couple of ways to do it, but they're all pretty long-winded and not really Pandas-like. Is there an elegant way of doing it?