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?

4
  • Can you share the log behind those numbers? Commented Oct 22, 2019 at 9:06
  • Possible duplicate of How to get the first column of a pandas DataFrame as a Series? Commented Oct 22, 2019 at 9:06
  • Can you explain your logic here? Commented Oct 22, 2019 at 9: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'. Commented Oct 22, 2019 at 9:21

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.