I have grouped a dataframe by count. It gives me a group by each value in the column I sepcified.
orig_df.groupby(['count_category'])['number_available'].count().reset_index()
To get example of my current output, use this table:
df = pd.DataFrame({'count_category': ['1','2','3','4','5'],'number_available': ['600','200','100','50','25'],})
| count_category | number_available |
|---|---|
| 1 | 600 |
| 2 | 200 |
| 3 | 100 |
| 4 | 50 |
| 5 | 25 |
What I want is to combine(sum) groups 4 and 5 to get an output like this:
| count_category | number_available |
|---|---|
| 1 | 600 |
| 2 | 200 |
| 3 | 100 |
| 4+ | 75 |
If I change all of the values that >=4 in the category, before I group, it will give me what I'm looking for. The only thing is that the label is 4 vs 4+, but this is what I was looking for.