I am trying to query a pandas dataframe for rows in which one column contains a tuple containing a certain value.
As an example:
User Col1
0 1 (cat, dog, goat)
1 1 (cat, sheep)
2 1 (sheep, goat)
3 2 (cat, lion)
4 2 (fish, goat, lemur)
5 3 (cat, dog)
6 4 (dog, goat)
7 4 cat
So assuming I want to return the rows where Col1 contains 'cat', is there a way to do this without iterating through each row and performing an "if" (my actual dataset has many more rows)?
df['Col1'].isin(['cat'])
and
df['Col1'].str.contains("cat")
only return 'true' for the last row