total pts resistance 1
0 0.5 0.872
1 2.0 1.770
2 0.0 0.246
3 2.0 3.500
4 0.5 1.069
5 1.0 0.793
6 0.5 nan
7 1.5 1.394
I use command like below
>>> df_new['total pts'].add(df_new['resistance 1 '],fill_value=0)
and it return error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/pandas/core/ops.py", line 686, in flex_wrapper
return self._binop(other, op, level=level, fill_value=fill_value)
File "/usr/local/lib/python2.7/dist-packages/pandas/core/series.py", line 1459, in _binop
result = func(this_vals, other_vals)
TypeError: unsupported operand type(s) for +: 'float' and 'str'
But it work perfectly with the below command
>>> df_new[['total pts','resistance 1 ']].sum(axis=1)
The issue is i can use sum to replace add but i need to do subtraction, division and multiplication. I want to know why these operator not working.
df.info()show? is thatnana realNaNor the string'nan'?stringtofloat:print df_new['total pts'].add(df_new['resistance 1'].astype(float), fill_value=0)