GOAL
I have a pandas dataframe with float and object types.
I want to group the dataframe by the 'name' column
groupped = df.groupby(["name"])
Than aggregate all the other columns.
There are columns with float values that I sum together
But I also have 'Object types' and the goal would be to just keep 1 object type ex.: the 1st one. They are the same. So I am trying to use min but it doesn't works but I can not find any other function for it that works with object types.
aggregated = groupped.agg({
'name' : ['min'],
'id' : ['min'],
'date' : ['min'],
'number_one' : ['sum'],
'type' : ['min'],
'number_two' : ['sum'],
})
ERROR
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-102-3594b7bd0c31> in <module>
9 'number_one' : ['sum'],
10 'type' : ['min'],
---> 11 'number_two' : ['sum'],
12 })
13
...
TypeError: '<=' not supported between instances of 'str' and 'float'
Already Tried
- pandas dataframe aggregate calculation
- Filtering Pandas Dataframe Aggregate
- Aggregating in panda dataframe
- Pandas - DataFrame aggregate behaving oddly
- Pandas Dataframe aggregating Statistics
- python pandas dataframe aggregate groupby
- Conditionally Aggregating Pandas DataFrame
- https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.agg.html