I have a dataframe in which one column contains tuples:
df = pd.DataFrame({'a':[1,2, 3], 'b':[(1,2), (3,4), (0,4)]}) ab 0 1 (1, 2) 1 2 (3, 4) 2 3 (0, 4)
I would like to select the rows in which the element I provide is in the tuple.
For example, return the lines where 4 is in the tuple, expect the result to be as follows:
ab 1 2 (3, 4) 2 3 (0, 4)
I tried:
print(df[df['b'].isin([4])]
But this returns an empty framework:
Empty DataFrame Columns: [a, b] Index: []
source share