Python Pandas: Create a DataFrame using dict of tuples

We can create pandas dataframe by using tuples.

Example

import pandas as pd

tup_names=("John","Jill","Monica","Joey","Alice")#create a tuple
tup_ages=(22,24,20,24,26)#create tuple
tup_fees=(True,False,True,True,False)

students=pd.DataFrame({'Name':tup_names ,
                       'Age':tup_ages,
                       'Fees Submitted':tup_fees})#create the pandas 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
Fri, 10/29/2021 - 18:41

Authored by

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.