Have some tricky situation. The Pandas Dataframe df
contains a column col
which has nested dictionaries as values looking like that:
{'code': 'D104',
'description': 'Error Occured',
'id': '5451235d',
'root_cause': 'Brokage'}
What I need to do is to find the occurrences of certain codes in string and replace the whole string with it, in example above it will be searching for 'D104'
and all the string will be just 'D104'
instead of dict.
I tried to apply .str.contains ()
on that column and use replace ()
function on the column but it seems to be that the trick is not working with dictionaries as values. Can you please guide me the way?