how to deal with variable length dict in python

Viewed 20

I am writing python code for dict. each heading has different lengths. Please let me know how to deal with it. below code is showing error "all arrays must be of the same length"

import pandas as pd

# Define a dictionary containing employee data
data = {'Name':['Jai', 'Princi', 'Gaurav', 'Anuj'],
    'Age':[27, 24, 22, 32],
    'Address':['Delhi', 'Kanpur', 'Allahabad', 'Kannauj'],
    'Qualification':['Msc', 'MA', 'MCA']}

Convert the dictionary into DataFrame

df = pd.DataFrame(data)

select two columns

print(df[['Name', 'Qualification']])
0 Answers
Related