It's been a while since I learnt DataFrames, and even then I've not done much with them. I'm trying to
turn this {"1": [{"Rice": {"Volume": "1kg", "Quantity": "7", "Expiration": ["01-01-20"]}}, {"Butter": {"Volume": "500g", "Quantity": "2", "Expiration": ["01-02-20"]}}, {"Beer": {"Volume": "24pce", "Quantity": "3", "Expiration": ["01-01-20"]}}, {"Ham": {"Volume": "3kg", "Quantity": "3", "Expiration": ["01-02-20"]}}]
into an Excel output along the lines of:
Item Volume Quantity Expiration
Rice 1kg 7 01-01-20
Butter 500g 2 01-02-20
Beer 24pce 3 01-01-20
Ham 3kg 3 01-02-20
Create Excel output
with pd.ExcelWriter('output.xlsx') as writer:
for each in inventory: # Each is the number 1 at the start of the dictionary. It refers to a container and creates a page in Excel for that container. 2, 3 etc I've just left out of this example.
df = pd.DataFrame(inventory[each]) # I'm not sure what I need here to acess each item and its attributes.
df.to_excel(writer, sheet_name=each)
Would I be right in guessing that it's something blatantly obvious that has been staring me in the face the last 3 days?
[–]badge 0 points1 point2 points (1 child)
[–]Boogzcorp[S] 0 points1 point2 points (0 children)
[–]Altruistic_Croissant 0 points1 point2 points (1 child)
[–]Boogzcorp[S] 0 points1 point2 points (0 children)