filmov
tv
Convert Dictionary to pandas DataFrame in Python (Example) | How to Create Row & Column from Dict

Показать описание
Python code of this video:
my_dict = {'x1': 5, # Create example dictionary
'x2': 24,
'x3': 2,
'x4': 13,
'x5': 22}
print(my_dict) # Print example dictionary
# {'x1': 5, 'x2': 24, 'x3': 2, 'x4': 13, 'x5': 22}
import pandas as pd # Load pandas library
my_data = pd.DataFrame([my_dict]) # Apply DataFrame() function
print(my_data) # Print pandas DataFrame
Follow me on Social Media:
my_dict = {'x1': 5, # Create example dictionary
'x2': 24,
'x3': 2,
'x4': 13,
'x5': 22}
print(my_dict) # Print example dictionary
# {'x1': 5, 'x2': 24, 'x3': 2, 'x4': 13, 'x5': 22}
import pandas as pd # Load pandas library
my_data = pd.DataFrame([my_dict]) # Apply DataFrame() function
print(my_data) # Print pandas DataFrame
Follow me on Social Media: