• Register
+1 vote
60 views

Problem :

I am receiveing error as
the truth value of a dataframe is ambiguous. use a.empty, a.bool(), a.item(), a.any() or a.all().
by (6.9k points)  

1 Answer

0 votes

Solution :

As far as i know pandas use bitwise '&' '|' and each condition should be wrapped in a '()'

For e.g. following works

data_query = data[(data['year'] >= 2005) & (data['year'] <= 2010)]

But the same query without proper brackets will not work

data_query = data[(data['year'] >= 2005 & data['year'] <= 2010)]
So try above steps to get rid of your issue.
by (36.1k points)  
...