2

I am very much new in Pandas . My code snippet is below

filtered_sales_user = df_sales_User.drop('custid',axis=1).groupby('runseq').mean()

Basically I am grouping dataframe by runseq and calculating the mean.

But for a dataframe below, where few columns are NaN I am getting below error.

custid        m1    m2  m3  m4  m5       m12       m13       m14  \
0    4894  0.637958  0.01 NaN NaN NaN  0.189322  0.211065  0.002590
1    8080  0.854400   NaN NaN NaN NaN  0.009367  0.065700  0.012541

        m6      m7  b1  b3           b40   b41  runseq  net_sales
0  Money_Funds  Growth NaN NaN  3.171390e+06  18.0      29        NaN
1  Money_Funds    None NaN NaN  5.551656e+05  15.0      29        NaN 

Error from server: code=2200 [Invalid query] message="Unable to make float from 'nan'"

Now should I replace all the NaN using fillna to fix this issue. And also will it hamper my mean calculation .

curiousguy
  • 3,212
  • 8
  • 39
  • 71

0 Answers0