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.
Learn Flask development and learn to build cool apps with our premium Python course on Udemy.
Subscribe to be the first to know when a new Python course is released.