0

My input dataframe;

Stock  PO      Order_test  Order
50     50      10          0
50     20      10          7
10     5       3           3
100    80      5           4

I want to filter the with this code;

a= df[(df['Stock'] - df['PO'])>(df['Order_Test']) & (df['Order_Test'])>(df['Order'])]

But i got this;

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

Desired output is;

   Stock  PO      Order_test  Order
   50     20      10          7
   100    80      5           4

Could you please help me about this?

1 Answer 1

1

You are close, only remove some () for enclose both conditions:

df = df[(df['Stock'] - df['PO']>df['Order_test']) & (df['Order_test']>df['Order'])]
        ^                                       ^   ^                            ^
      start                                    end start                        end   

print (df)
   Stock  PO  Order_test  Order
1     50  20          10      7
3    100  80           5      4
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.