Unpack list of dictionary into Pandas dataframe
Remove the leading 0 and call pd.DataFrame() on the remaining part.
I've been trying to unpack this like a dictionary or json in python pandas but it's not giving me an output into a dataframe. Can anyone point me in the right direction?
0      [{'JournalLineID': 'XXX', 'AccountID': 'XXX', 'AccountCode': '200', 'AccountType': 'XXX', 'AccountName': 'XXX', 'Description': '', 'NetAmount': -428.0, 'GrossAmount': -428.0, 'TaxAmount': 0.0, 'TrackingCategories': [{'Name': 'Location', 'Option': 'SG', 'TrackingCategoryID': 'XXX', 'TrackingOptionID': 'XXX', 'Options': []}, {'Name': 'Sales Rep/Dept', 'Option': 'HQ', 'TrackingCategoryID': 'XXX', 'TrackingOptionID': 'XXX', 'Options': []}]}, {'JournalLineID': 'XXX2', 'AccountID': 'XXX', 'AccountCode': 'XXX', 'AccountType': 'EXPENSE', 'AccountName': 'Subscriptions - Software', 'Description': 'XXXX', 'NetAmount': 400.0, 'GrossAmount': 428.0, 'TaxAmount': 28.0, 'TaxType': 'INPUT', 'TaxName': 'Purchases 7%', 'TrackingCategories': [{'Name': 'Location', 'Option': 'SG', 'TrackingCategoryID': 'XXX', 'TrackingOptionID': 'XXX', 'Options': []}, {'Name': 'Sales Rep/Dept', 'Option': 'HQ', 'TrackingCategoryID': 'XXX', 'TrackingOptionID': 'XXX', 'Options': []}]}]
When i try pd.DataFrame.from_records(df), it gives me an output that splits by the letter
0    [   {   '   J   o   u   r   n   a   l   ... s   '   :       [   ]   }   ]   }   ]
When i try pd.DataFrame(df),
this is the output:
0    [{'JournalLineID': 'XXX', 'AccountID': 'XXX', 'AccountCode': '200', 'AccountType': 'XXX', 'AccountName': 'XXX', 'Description': '', 'NetAmount': -428.0, 'GrossAmount': -428.0, 'TaxAmount': 0.0, 'TrackingCategories': [{'Name': 'Location', 'Option': 'SG', 'TrackingCategoryID': 'XXX', 'TrackingOptionID': 'XXX', 'Options': []}, {'Name': 'Sales Rep/Dept', 'Option': 'HQ', 'TrackingCategoryID': 'XXX', 'TrackingOptionID': 'XXX', 'Options': []}]}, {'JournalLineID': 'XXX2', 'AccountID': 'XXX', 'AccountCode': 'XXX', 'AccountType': 'EXPENSE', 'AccountName': 'Subscriptions - Software', 'Description': 'XXXX', 'NetAmount': 400.0, 'GrossAmount': 428.0, 'TaxAmount': 28.0, 'TaxType': 'INPUT', 'TaxName': 'Purchases 7%', 'TrackingCategories': [{'Name': 'Location', 'Option': 'SG', 'TrackingCategoryID': 'XXX', 'TrackingOptionID': 'XXX', 'Options': []}, {'Name': 'Sales Rep/Dept', 'Option': 'HQ', 'TrackingCategoryID': 'XXX', 'TrackingOptionID': 'XXX', 'Options': []}]}]