You can create a DataFrame many different ways. One popular way to do it is creating a pandas DataFrame from dict, or dictionary.
There are two main ways to create a go from dictionary to DataFrame, using orient=columns or orient=index. Orient is short for orientation, or, a way to specify how your data is laid out.
- Method 1 – Orient (default): columns = If you want the keys of your dictionary to be the DataFrame column names
- Method 2 – Orient: index = If the keys of your dictionary should be the index values. You’ll need to be explicit about column names.
Pandas DataFrame From Dict
Orient = Columns
You use orient=columns when you want to create a Dataframe from a dictionary who’s keys you want to be the columns. Usually your dictionary values will be a list containing an entry for every row you have.
Check out the picture below to see

Orient = Index
You use orient=Index when you want the values of your dictionary to be the index of your DataFrame. Be sure to specify your columns when creating your DataFrame or else they’ll just be numbers.
Check out the code sample below for an example using both methods to create a pandas dataframe from dict
import pandas as pd
Start with a dictionary of data¶
Creating a dataframe from a dictionary is easy and flexible. Let's look at two ways to do it here:
- Method 1 - Orient (default): columns = If you want the keys of your dictionary to be the DataFrame column names
- Method 2 - Orient: index = If the keys of your dictionary should be the index values. You'll need to be explicit about column names.
Method 1 - Orient (default): columns = If you want the keys of your dictionary to be the DataFrame column names¶
First create a dictionary of data where the keys are your column names. Here my column names will be 1) Name 2) Type 3) AvgBill
dict_data_column_keys = {
"Name": ["Liho Liho", "500 Club", "Foreign Cinema", "The Square"],
"Type": ["Restaurant", "Bar", "Restaurant", "Bar"],
"AvgBill": [200.45, 34.64, 180.45, 45.54]
}
Then call pd.DataFrame.from_dict() and pass your data in the function. Because orient=columns is the default, we do not need to specify orient below.
pd.DataFrame.from_dict(dict_data_column_keys)
Passing orient="columns" yields the same result since this is the default value
pd.DataFrame.from_dict(dict_data_column_keys, orient='columns')
Method 2 - Orient: Rows = If the keys of your dataframe should be the DataFrame index¶
Let's again first create a dictionary, but this time the keys are your index. Here my index will be my previous "name" column and the columns will be 1) Type 2) AvgBill
dict_data_index_keys = {
"Liho Liho": ["Restaurant", 200.45],
"500 Club": ["Bar", 34.64],
"Foreign Cinema": ["Restaurant", 180.45],
"The Square": ["Bar", 45.54]
}
pd.DataFrame.from_dict(dict_data_index_keys, orient='index')
Whoops, as you can see, I don't have any column names! Make sure to specify your column names if you do orient=index
pd.DataFrame.from_dict(dict_data_index_keys, orient='index', columns=['Type', 'AvgBill'])
Reach out if you have any questions about going from a a dict to pandas DataFrame
Check out more Pandas functions on our Pandas Page