0

I have a DataFrame in Pandas that goes like:

| Age_Group | UF  |
|:-------- |:----:|
| [0,20]   | 2    |
| [45,60]  | 1    |
| [0,20]   | 0    |
| [20,45   | 5    |
| [0,20]   | 3    |

I want to create a new DataFrame with two columns: Age_group and UF_sum:

| Age_Group | Sum_UF  |
|:-------- |:----:|
| [0,20]   | 5    |
| [45,60]  | 1    |
| [20,45]  | 5    |

I know how to create a third column by summing other ones, but I am stucked on how to put a condition and select the age groups properly. Any help?

Dimitri
  • 97
  • 1
  • 10

0 Answers0