I have referred this: Nested Json to pandas DataFrame with specific format
and this: json_normalize produces confusing KeyError
to try and normalize my json snippet using json_normalize in pandas. However, the output isn't getting normalized fully. Here's a snippet of my code
x =[{'fb_metrics': [{'period': 'lifetime', 'values': [{'value': {'share': 2, 'like': 10}}], 'title': 'Lifetime Post Stories by action type', 'name': 'post_stories_by_action_type', '_id': '222530618111374_403476513350116/insights/post_stories_by_action_type/lifetime', 'description': 'Lifetime: The number of stories created about your Page post, by action type. (Total Count)'}]}]
df = pd.io.json.json_normalize(x[0]['fb_metrics'])
The output for values column is
values
[{'value': {'share': 2, 'like': 10}}]
I would've liked to have two column outputs instead like
value.share value.like
2 10
How should I achieve this?