1data = {'col_1': [3, 2, 1, 0], 'col_2': ['a', 'b', 'c', 'd']}
2pd.DataFrame.from_dict(data)
1>>> data = {'row_1': [3, 2, 1, 0], 'row_2': ['a', 'b', 'c', 'd']}
2>>> pd.DataFrame.from_dict(data, orient='index')
3 0 1 2 3
4row_1 3 2 1 0
5row_2 a b c d
6
1create a dataframe from dict (function)
2
3import pandas as pd
4def create_df():
5 data = {'col_1': [3, 2, 1, 0], 'col_2': ['a', 'b', 'c', 'd']}
6 return pd.DataFrame.from_dict(data)
7create_df()