Pandas DataFrame from Dict

  • Post category:Pandas

In this Pandas tutorial, you will learn how to create a Pandas DataFrame from dict in Python. You can easily make a Pandas DataFrame from a dictionary with the following code.

# import Pandas library
import pandas as pd

# create a dictionary
data = {'A': [30, 40, 50, 60], 'B': [70, 80, 90, 10], 'C': [20, 30, 40, 50]}

# create a dataframe from dictionary
var = pd.DataFrame(data)

# display the dataframe
print(var)

Output:

    A   B   C
0  30  70  20
1  40  80  30
2  50  90  40
3  60  10  50

Free resources to learn advanced skills: AiHints and CodeAllow