Given a dataframe df['serialnumber', 'basicinfo'], the column "basicinfo" is a dict {'name': xxx, 'model': xxx, 'studyid': xxx}.
Is there an easy way to filter this dataframe by the dict key "model"?
We can do this filtered by 'serialnumber' if it is integer:
df = df[df.serialnumber == <value>]
How to do that for dict column?
You won't get the vectorized operations directly. But you could use apply
to get the dictionary value from.
df = df[df.basicinfo.apply(lambda x: x['model'] == <value>)]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With