I have a similar question to this one
I have a dataframe in pandas that looks like this - showing ages at which different users won awards.
| id | awards | age | 
|---|---|---|
| 1 | 100 | 24 | 
| 1 | 150 | 26 | 
| 1 | 50 | 54 | 
| 2 | 193 | 34 | 
| 2 | 209 | 50 | 
Interested in computing total awards for age intervals i.e. 0 (0-8 years old), 1 (9 - 17 years old), 2 (18-26 years old), 3 (27-35 years old), 4 (26 - 44 years old) ... etc. Each person should have as many age intervals as necessary for the oldest person
How can I group them by id and by 9 year age intervals to get something like this:
| id. | total_awards | age_interval | 
|---|---|---|
| 1 | 0 | 0 | 
| 1 | 0 | 1 | 
| 1 | 250 | 2 | 
| 1 | 0 | 3 | 
| 1 | 0 | 4 | 
| 1 | 0 | 5 | 
| 1 | 50 | 6 | 
| 2 | 0 | 0 | 
| 2 | 0 | 1 | 
| 2 | 0 | 2 | 
| 2 | 193 | 3 | 
| 2 | 0 | 4 | 
| 2 | 209 | 5 | 
| 2 | 0 | 6 | 
 
     
    