Python Forum
Transform Facebook Graph API insights JSON to pandas dataframe - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: Transform Facebook Graph API insights JSON to pandas dataframe (/thread-24756.html)



Transform Facebook Graph API insights JSON to pandas dataframe - usman - Mar-03-2020

I am trying to read my Page INSIGHTS from Facebook graph API and then convert into pandas dataframe but unable to do so.

I used json_normalize function but i did not help me

Here is my JSON
[{'name': 'page_impressions',
      'period': 'day',
      'values': [{'value': 0, 'end_time': '2020-01-02T08:00:00+0000'},
       {'value': 0, 'end_time': '2020-01-03T08:00:00+0000'},
       {'value': 0, 'end_time': '2020-01-04T08:00:00+0000'},
       {'value': 0, 'end_time': '2020-01-05T08:00:00+0000'},
       ],
      'title': 'Daily Total Impressions',
      'description': "Daily: The number of times any content from your Page or about your Page entered a person's screen. This includes posts, stories, check-ins, ads, social information from people who interact with your Page and more. (Total Count)",
      'id': '761993803915367/insights/page_impressions/day'},
     {'name': 'page_fans',
      'period': 'day',
      'values': [{'value': 587, 'end_time': '2020-01-02T08:00:00+0000'},
       {'value': 587, 'end_time': '2020-01-03T08:00:00+0000'},
       {'value': 587, 'end_time': '2020-01-04T08:00:00+0000'},
       {'value': 587, 'end_time': '2020-01-05T08:00:00+0000'}],

      'title': 'Lifetime Total Likes',
      'description': 'Lifetime: The total number of people who have liked your Page. (Unique Users)',
      'id': '761993803915367/insights/page_fans/day'}]
Sample Expected Output in dataframe
Output:
page_impressions | page_fans | end_time 0 587 2020-01-03T08:00:00+0000