-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Open
Labels
EnhancementError ReportingIncorrect or improved errors from pandasIncorrect or improved errors from pandas
Description
Currently, if one writes
>>> import pandas as pd
>>> df = pd.DataFrame([1,2,3])
>>> df
0
0 1
1 2
2 3
>>> df[df[0].ge(0) and df[0].lt(0)]
then the traceback shows
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/marco/pandas-dev/pandas/core/generic.py", line 1326, in __nonzero__
raise ValueError(
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
I've noticed that Kaggle add their own warning when someone tries to do this:
To combine filtering conditions in Pandas, use bitwise operators ('&' and '|') not pure Python ones ('and' and 'or')
See below:
Is this something that could be in pandas as well? Sure, there's no way of reading users' minds - perhaps they reached this error by some other means - but would the error message be clearer if there was an extra line reading
If you were trying to combine filtering conditions in Pandas, use bitwise operators ('&' and '|') instead of pure Python ones ('and' and 'or')
?
erfannariman and samukweku
Metadata
Metadata
Assignees
Labels
EnhancementError ReportingIncorrect or improved errors from pandasIncorrect or improved errors from pandas