So I am working on a dataset and I have a column that consists of country ids and country names in dict format. But when I try to evaluate the dictionary, I see that it is actually a string.
When I print a column it seems like this:
df["production_countries"][0]
[{"iso_3166_1": "US", "name": "United States of America"}, {"iso_3166_1": "GB", "name": "United Kingdom"}]
When I try to add a new column from this dictionaries, I see that it is a string inside the list. So how can I evaluate this seemingly list of dicts to make actual list of dicts?
I wanted to add a column that give 1 or 0 if the US values exists in that column.
df["US_count"] = df["production_countries"].apply(lambda x:\
[[int(d["name"] == "United States") for d in dicts] for dicts in x])