python - How to get the max/min value in Pandas DataFrame when nan value in it -


since 1 column of pandas dataframe has nan value, when want max value of column, return error.

>>> df.iloc[:, 1].max() 'error:512' 

how can skip nan value , max value of column?

you can use numpy's np.nanmax, np.nanmin :

in [28]: df out[28]:       b  c 0  7 nan  8 1  3   3  5 2  8   1  7 3  3   0  3 4  8   2  7  in [29]: np.nanmax(df.iloc[:, 1].values) out[29]: 3.0  in [30]: np.nanmin(df.iloc[:, 1].values) out[30]: 0.0 

Comments