import pandas # Create a sample dictionary of str:list mydata = {'Celsius':[10, 20, 30], 'Fahr':[4, 5, 6], 'Kelvin':[7,8,9]}
# Create dataframe from the dictionary df = pandas.DataFrame(mydata)
# Print out the dataframe print(df)
Celsius Fahr Kelvin
0 10 4 7
1 20 5 8
2 30 6 9
Since the structure of a pandas dataframe is similar to that of a Python dictionary, it is enough to provide the dictionary as an argument to the DataFrame class and we end up with a dataframe object. Notice that the dictionary keys are transformed into dataframe columns names.
Python Mega Course: Learn Python in 60 Days, Build 20 Apps
Learn Python on Udemy completely in 60 days or less by building 20 real-world applications from web development to data science.