I am reading from an API which returns JSON I am using
from pandas.io.json import json_normalize
flatten = json_normalize(data['results'])
To flatten the JSON and now the output is like
breakdowns metric time value
0 [{u'key': u'platform', u'value': u'ios'}] fb_ad_network_imp 2018-08-29T07:00:00+0000 12
1 [{u'key': u'platform', u'value': u'android'}] fb_ad_network_imp 2018-08-29T07:00:00+0000 32
2 [{u'key': u'platform', u'value': u'ios'}] fb_ad_network_request 2018-08-29T07:00:00+0000 33
3 [{u'key': u'platform', u'value': u'android'}] fb_ad_network_request 2018-08-29T07:00:00+0000 132
now I want to squash these 4 rows into 2 based on the platform, something like this:
platform date clicks impressions
0 ios 2018-08-29 33 12
1 android 2018-08-29 132 32
I have also mapped these names:
fb_ad_network_request -> clicks
fb_ad_network_imp -> impressions
what's the best way to do that?