将 Facebook Graph API 见解 JSON 转换为 pandas 数据帧

Transform Facebook Graph API insights JSON to pandas dataframe

提问人:Usman Rafiq 提问时间:3/2/2020 最后编辑:bharatkUsman Rafiq 更新时间:3/2/2020 访问量:225

问:

我正在尝试从 Facebook 图形 API 读取我的页面见解,然后转换为 pandas 数据帧,但无法这样做。

我使用了json_normalize功能,但我没有帮助我

这是我的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'}]

数据帧中的预期输出示例

page_impressions  | page_fans  |  end_time

 0                587       2020-01-03T08:00:00+0000 
Python 熊猫

评论


答: 暂无答案