I'm attempting to convert several dictionaries contained in an array to a pandas dataframe. The dicts are saved as such:
[[{u'category': u'anti-social-behaviour',u'location': {u'latitude': u'52.309886',
u'longitude': u'0.496902'},u'month': u'2015-01'},{u'category': u'anti-social-behaviour',u'location': {u'latitude': u'52.306209',
u'longitude': u'0.490475'},u'month': u'2015-02'}]]
I'm trying to format my data to the format below:
Category Latitude Longitude
0 anti-social 524498.597 175181.644
1 anti-social 524498.597 175181.644
2 anti-social 524498.597 175181.644
. ... ...
. ... ...
. ... ...
I've tried to force the data into a dataframe with the below code but it doesn't produce the intended output.
for i in crimes:
for x in i:
print pd.DataFrame([x['category'], x['location']['latitude'], x['location']['longitude']])
I'm very new to Python so any links/tips to help me build this dataframe would be highly appreciated!