This is the data frame I have:
data = {
'names': ['Rose', 'Rose', 'Tulip', 'Tulip', 'Lily'],
'f': [10, 20, 5,15, 30],
'h': [5, 8, 6, 12, 10],
'date':['2023-01-01', '2023-02-01', '2023-02-01', '2023-03-01', '2023-04-01']
}
How can I create this?
Rose Tulip Lily
f h f h f h
2023-01-01 10 5 0 0 0 0
2023-02-01 20 8 5 6 0 0
2023-03-01 0 0 15 12 0 0
2023-04-01 0 0 0 0 30 10
I think you want to pivot the data:
Prints: