Search code examples
pythonpandasnumpynanzero

Find Minimum without Zero and NaN in Pandas Dataframe


I have a pandas Dataframe and I want to find the minimum without zeros and Nans. I was trying to combine from numpy nonzero and nanmin, but it does not work.

Does someone has an idea?


Solution

  • If you want the minimum of all df, you can try so:

    m = np.nanmin(df.replace(0, np.nan).values)