I have a pandas series with foll. value_counts output():
NaN 2741
197 1891
127 188
194 42
195 24
122 21
When I perform describe() on this series, I get:
df[col_name].describe()
count 2738.000000
mean 172.182250
std 47.387496
min 0.000000
25% 171.250000
50% 197.000000
75% 197.000000
max 197.000000
Name: SS_D_1, dtype: float64
However, if I try to find minimum and maximum, I get nan as answer:
numpy.min(df[col_name].values)
nan
Also, when I try t convert it to a numpy array, I seem to get an array with only nan's
numpy.array(df[col_name])
Any suggestion on how to convert from pandas series to numpy array succesfully
df[col_name].valueswill return the numpy array. If you have a NaN in the data, it gets propagated using the numpy.min function. Meaning if there is a NaN, np.min will always yield the NaN as the anser. Try nanmin docs.scipy.org/doc/numpy/reference/generated/…minof any array containingnanis alsonan. To ignorenanvalues, trynp.nanmin(df[col_name].values)(or justdf[col_name].min()).min()method.pandas.Series.min()does the equivalent ofnp.nanminand ignores nan values, whereasnumpy.ndarray.mindoes the equivalent ofnp.minand will returnnanfor an array that contains one or morenans..arrayand.to_numpy- please find an updated answer bellow. pandas 0.24.x release notes