I have a pandas dataframe that contains arrays within some of its columns. I'd like to filter the dataframe to only contain rows that have a certain value found in the nested array for that column.
For example, I have a dataframe something like this:
label MODEL_INDEX ARRAY_VAL
ID
0 4 (11.0, 0.0)
1 65 (11.0, 10.0)
2 73 (11.0, 10.0)
3 74 (10.0, 0.0)
4 79 (11.0, 0.0)
5 80 (10.0, 0.0)
6 88 (11.0, 0.0)
And I'd like to filter the dataframe to only include those satisfying some variable condition, say containing 10.0, in the array under ARRAY_VAL to get this:
label MODEL_INDEX ARRAY_VAL
ID
1 65 (11.0, 10.0)
2 73 (11.0, 10.0)
3 74 (10.0, 0.0)
5 80 (10.0, 0.0)
Essentially, looking for something like:
df[df['ARRAY_VAL'] where 10.0 in df['ARRAY_VAL]]