I am trying to extract a dataframe from the built-in seaborn dataset diamond that satisfies two conditions :
- i) The cut is 'ideal'
- ii) The color is 'E'.
The code snippet is below:
import pandas as pd
import seaborn as sns
diam = sns.load_dataset("diamonds")
cut_col = diam[(diam['cut'] == "Ideal") and (diam['color'] == "E"]
This gives me the following ValueError:
File "C:\Users\logic\Anaconda3\lib\site-packages\pandas\core\generic.py", line 1555, in __nonzero__
self.__class__.__name__
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
But if I replace the logical operator 'and' with the bitwise operator '&', the code runs fine. Can anyone explain the reason behind this? Why the logical-AND operator does not work in this case?