0

My input dataframe:

    A         Min Thresh   Max Thresh
    0          1          
    0                          10
    15.5       1               11
    13.3                       15
    10         0               15

Desired output:

A
1
0
11
13.3
10

Could you please help me about this?

Salih
  • 719
  • 1
  • 6
  • 12
  • Can you share the log behind those numbers? – Aaron_ab Oct 22 '19 at 09:06
  • Possible duplicate of [How to get the first column of a pandas DataFrame as a Series?](https://stackoverflow.com/questions/15360925/how-to-get-the-first-column-of-a-pandas-dataframe-as-a-series) – micharaze Oct 22 '19 at 09:06
  • Can you explain your logic here? – Erfan Oct 22 '19 at 09:13
  • @Erfan He meant that if the value in column 'A' is below the value in column 'Min Thresh' then is should recieve the value of 'Min Thresh', and the same for 'Max Thresh'. – Aryerez Oct 22 '19 at 09:21

1 Answers1

2

You can do:

df['A'] = df[['A', 'MinThresh']].max(axis=1)
df['A'] = df[['A', 'MaxThresh']].min(axis=1)

It ignores np.nan, as you need.

Aryerez
  • 3,417
  • 2
  • 9
  • 17