New to pandas, I m climbing my learning curve here. I have a dataframe that looks like:
Relinquished Degree Count DTD DNP outindefinitely seasonout
------------
df.groupby('Relinquished').sum()
You cannot replace missing values to empty strings in first step and then aggregate sum
:
df = df.groupby('Relinquished').sum()
If want specify columns for sum:
print (df)
Relinquished Degree Count DTD DNP outindefinitely seasonout
0 player1 1 1 1.0 NaN NaN NaN
1 player1 3 1 NaN NaN 1.0 NaN
df = df.groupby('Relinquished')['DTD','DNP','outindefinitely','seasonout'].sum()
print (df)
DTD DNP outindefinitely seasonout
Relinquished
player1 1.0 0.0 1.0 0.0