Suppose I have a df like this-
A B
1 {'meta': 3}
2 {'meta': 3}
3 {'tera': 3}
I want to retrieve the int value from column-B.
Desired Dataframe-
A B
1 3
2 3
3 3
Thanks in advance.
CodePudding user response:
Column B is a dict, so let's get the value corresponding to the key.
As we don't know the key name, take the first value.
It's already an integer. No conversion needed.
df["B"] = df["B"].map(lambda x: list(d.values())[0])