I have a small Pandas DataFrame I'd like to resample, and I hoped you could help me :)
I cannot show it to you as it is confidential but I can describe to you a simpler version of it.
It has 4 columns:
-Date (YYYY-MM-DD format)
-Country
-Amount
-Frequency
So here is what I'd like to do:
Depending on the rows, the Frequency is either YEARLY or MONTHLY If it happens to be monthly, then nothing needs to be done.
But if it's YEARLY, I would like to change it to MONTHLY and insert 11 new rows so that in the 12 rows (the existing one and the 11 new ones) considered, the country would remain the same (so same country name repeted 12 times), the amount would be amount/12 (repeted 12 times too, you get it), and the date would be incremented by 1 month at each row.
I really wish someone could help me with that!
Thanks in advance,
Alex
EDIT:
I already change the Date Column as an index using
df.set_index("Date",inplace=True)
However, I don't really know how to use the resample function for my purpose...