The conversion of Python dict into dataframe is very simple, to achieve this you will need to make use of the pandas library.
Example:import pandas as pd
country_capitals_dict = {
'Country': ['United States', 'Canada', 'Germany', 'France'],
'Capital': ['Washington D.C.', 'Ottawa', 'Berlin', 'Paris']
}
# Convert dictionary to DataFrame
df = pd.DataFrame(country_capitals_dict)
print(df)
Output:
Country Capital
0 United States Washington D.C.
1 Canada Ottawa
2 Germany Berlin
3 France Paris
4 China Beijing
5 India New Delhi
6 Nigeria Abuja
7 South Africa Pretoria
References:
Pandas: https://pandas.pydata.org/docs/
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!