I have a pandas dataframe as:
ID | Date | Value |
---|---|---|
A | 1/1/2000 | 5 |
A | 2/1/2000 | 10 |
A | 3/1/2000 | 20 |
A | 4/1/2000 | 10 |
B | 1/1/2000 | 100 |
B | 2/1/2000 | 200 |
B | 3/1/2000 | 300 |
B | 4/1/2000 | 400 |
How do I evaluate the monthly fraction of the total yearly value for each ID as the fourth column?
ID | Date | Value | Fraction |
---|---|---|---|
A | 1/1/2000 | 5 | 0.11 |
A | 2/1/2000 | 10 | 0.22 |
A | 3/1/2000 | 20 | 0.44 |
A | 4/1/2000 | 10 | 0.11 |
B | 1/1/2000 | 100 | 0.11 |
B | 2/1/2000 | 200 | 0.22 |
B | 3/1/2000 | 300 | 0.33 |
B | 4/1/2000 | 400 | 0.44 |
I guess I could use groupby?