I'm doing something like
dfAgg = df.groupby('col1').agg({'col2': (", ").join,
'col3':'first',
'col4': sum,
}).reset_index()
and I get
TypeError: sequence item 0: expected str instance, NoneType found
There are None values in my col2. Is there a way to ignore those with join
?
Give it a try with a lambda expression
custom_agg = lambda ar: ', '.join([item for item in ar if item])
dfAgg = df.groupby('col1').agg({'col2': custom_agg,
'col3':'first',
'col4': sum,
}).reset_index()