Python Pandas: Create a DataFrame using list

Pandas DataFrame is a 2-Dimensional data structure aligned in a tabular fashion in rows and columns. We can create Pandas DataFrame in many different ways some are explained here:

This is the simplest and easiest way to create the dataframe.

Example

import pandas as pd

names=["John","Jill","Monica","Joey","Alice"]#create a list
ages=[22,24,20,24,26]#create another list
fees=[True,False,True,True,False]
students=pd.DataFrame({'Name':names ,'Age':ages,'Fees Submitted':fees})#create the pandas dataframe

print(students) #print dataframe

Output

     Name  Age  Fees Submitted
0    John   22            True
1    Jill   24           False
2  Monica   20            True
3    Joey   24            True
4   Alice   26           False