I have a DataFrame where one column/field is a long list of dictionaries. I want to only keep rows in a subset of the DataFrame where the list of dictionaries contains a certain dictionary entry. I don't want to filter the list of dictionaries, just retrieve rows where the desired entry exists (usually among many other entries) keeping all other columns/fields intact.
Here's a mock df
df = pd.DataFrame({'bird': ['robin', 'jay', 'pelican', 'duck'], 'beaky': ['yes', 'yes', 'yes', 'yes'], 'feathers': [[{'type':'thing', 'id':'1a'}, {'type':'thing', 'id':'5a'}] , [{'type': 'thing', 'id':'2a'},{'type':'thing', 'id':'1a'}],[{'type': 'thing', 'id':'3a'},{'type': 'thing', 'id':'4a'}],[{'type':'thing', 'id':'2a'}, {'type':'thing', 'id':'3a'}]]})
df
Pseudo code for the df example above...
Select rows of the DataFrame where df['feathers'] contains {'type': 'thing', 'id': '3a'}