0

Hi I have a rather simple task but seems like all online help is not working. I have data set like this:

ID   |  Px_1       | Px_2
theta|  106.013676 | 102.8024788702673
Rho  |  100.002818 | 102.62640389123405
gamma|  105.360589 | 107.21999706084836
Beta |  106.133046 | 115.40449479551263
alpha|  106.821119 | 110.54312246081719

I want to find min by each row in a fourth col so the output I can have is for example, theta is 102.802 because it is the min value of both Px_1 and Px_2

I tried this but doesnt work I constantly get max value

df_subset = read.set_index('ID')[['Px_1','Px_2']]
d = df_subset.min( axis=1) 

Thanks

1
  • You get the max value by using the min function? Commented Dec 31, 2017 at 4:37

1 Answer 1

2

You can try this

df["min"] = df[["Px_1", "Px_2"]].min(axis=1)

Select the columns needed, here ["Px_1", "Px_2"], to perform min operation.

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.