I have a following data and need on first step to find min values among rows without 0.00
HOME_48  HOME_24  HOME_12  HOME_03  HOME_01  HOME_00   HOME  
   0.00     1.54     2.02     1.84     1.84     1.84   1.84  
   0.00     1.47     1.76     1.89     2.56     2.56   2.56  
   0.00     2.02     2.50     2.56     1.89     1.92   1.92  
Later I need calculate delta-diff between min and max, but if I use below code, the end-results are not acceptable
df['HOME_MIN'] = df.loc[:, COL_HOME].min(axis=1)
I don't want use following tricks:
df = df.replace(0, np.NaN)
Beacuse, sometimes the extreme values can be equal as 0.01, 0.02 - these ones are not correct values also.
How can I add condition to skip 0.00| 0.01 values?
NOTE: correct filter is
df[df[COL_HOME].min(axis=1) > 0.03].loc[:, COL_HOME].min(axis=1)
                Pandas DataFrame min() Method The min() method returns a Series with the minimum value of each column. By specifying the column axis ( axis='columns' ), the max() method searches column-wise and returns the minimum value for each row.
notna() function detects existing/ non-missing values in the dataframe. The function returns a boolean object having the same size as that of the object on which it is applied, indicating whether each individual value is a na value or not.
Min value between two pandas columns You can do so by using the pandas min() function twice.
You could use a boolean filter to exclude whatever you don't want, like this.
In [46]: df[df > .01].min(axis=1)
Out[46]: 
0    1.54
1    1.47
2    1.89
dtype: float64
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With