Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.

Examples
The keys of the dict become the DataFrame columns by default:

In [1]:
import numpy as np
import pandas as pd
In [2]:
data = {'c_1': [4, 3, 2, 0], 'c_2': ['p', 'q', 'r', 's']}
pd.DataFrame.from_dict(data)
Out[2]:
c_1 c_2
0 4 p
1 3 q
2 2 r
3 0 s

Specify orient='index' to create the DataFrame using dictionary keys as rows:

In [3]:
data = {'row_1': [4, 3, 2, 0], 'row_2': ['p', 'q', 'r', 's']}
pd.DataFrame.from_dict(data, orient='index')
Out[3]:
0 1 2 3
row_1 4 3 2 0
row_2 p q r s

When using the ‘index’ orientation, the column names can be specified manually:

In [4]:
pd.DataFrame.from_dict(data, orient='index',
                       columns=['P', 'Q', 'R', 'S'])
Out[4]:
P Q R S
row_1 4 3 2 0
row_2 p q r s