I have a DataFrame in pandas, with one of the column types being a list on int, for example:
df = pandas.DataFrame([[1,2,3,[4,5]],[6,7,8,[9,10]]], columns=['a','b','c','d'])
>>> df
a b c d
0 1 2 3 [4, 5]
1 6 7 8 [9, 10]
I would like to create a filter using d, but normal comparison operations do not work:
>>> df['d'] == [4,5]
0 False
1 False
Name: d, dtype: bool
However, when I check line by line, I get what I expect
>>> df.loc[0,'d'] == [4,5]
True
What's going on here? How to perform list comparisons?
source
share