Pandas create Dataframe from Dictionary

In this tutorial, We will see different ways of Creating a pandas Dataframe from Dictionary .

Using a Dataframe() method of pandas.

Example 1 : When we only pass a dictionary in DataFrame() method then it shows columns according to ascending order of their names .

Output :

Example 2 : If we want to show a DataFrame with a specific order of columns then we have to pass a columns key word arguments alog with dictionary in the DataFrame method.

Output :

Using DataFrame.from_dict() method.

Example 1 : When we only pass a dictionary in DataFrame.from_dict() method then it shows columns according to ascending order of their names .

Output :

Example 2 : If we want to create a Dataframe using dictionary in which keys is act as rows then we have to Specify orient="index" in DataFrame.from_dict() method along with dictionary.

Output :

That’s all about how to create a pandas Dataframe from Dictionary

Was this post helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *