My original dataframe has the following columns -
I want to split the json_result column into separate columns like this:
I tried using json_normalise, but couldn't apply on the entire dataframe. Can someone share the code to transform the entire dataframe?
Adding the snippet that I have tried -
raw_data = [{'id': 1, 'name': 'NATALIE', 'json_result': '{"0": {"_source": {"person_id": 101, "firstname": "NATALIE", "lastname": "OSHO", "city_name": "WESTON"}}}'}, \
{'id': 2, 'name': 'MARK', 'json_result': '{"0": {"_source": {"person_id": 102, "firstname": "MARK", "lastname": "BROWN", "city_name": "NEW YORK"}}}'}, \
{'id': 3, 'name': 'NANCY', 'json_result': '{"0": {"_source": {"person_id": 103, "firstname": "NANCY", "lastname": "GATES", "city_name": "LA"}}}'}]
df = pd.DataFrame.from_dict(raw_data)
splitted_df = pd.json_normalize(df['json_result'][0])
Error Message:
AttributeError: 'str' object has no attribute 'values'


json_normalizebut it is hard to show you without data.