Screen Link: https://app.dataquest.io/m/355/list-comprehensions-and-lambda-functions/10/reading-json-files-into-pandas
My Code 1:
json_obj
Output 1 (I understand):
[{'name': 'Sabine', 'age': 36, 'favorite_foods': ['Pumpkin', 'Oatmeal']},
{'name': 'Zoe',
'age': 40,
'favorite_foods': ['Chicken', 'Pizza', 'Chocolate']},
{'name': 'Heidi', 'age': 40, 'favorite_foods': ['Caesar Salad']}]
My Code 2:
json_df = pd.DataFrame(json_obj)
json_df
Output 2 (I have a question about):
age favorite_foods name
0 36 [Pumpkin, Oatmeal] Sabine
1 40 [Chicken, Pizza, Chocolate] Zoe
2 40 [Caesar Salad] Heidi
My Question:
I’m using Python 3.7. Why isn’t dictionary key order preserved in DataFrame column order in Python 3.7? I thought dictionaries preserved their key order after something like Python 3.6.