Informatics Practices
Four dictionaries store the details of four employees-of-the-month as (empno, name). Write a program to create a dataframe from these.
Answer
import pandas as pd
emp1 = {'empno': 1001, 'name': 'Ameesha'}
emp2 = {'empno': 1002, 'name': 'Akruti'}
emp3 = {'empno': 1003, 'name': 'Prithvi'}
emp4 = {'empno': 1004, 'name': 'Rajesh'}
employees = [emp1, emp2, emp3, emp4]
df = pd.DataFrame(employees)
print(df)Output
empno name
0 1001 Ameesha
1 1002 Akruti
2 1003 Prithvi
3 1004 Rajesh
Related Questions
Write a program to create a Series object that stores the table of number 5.
Write a program to create a Dataframe that stores two columns, which store the Series objects of the previous two questions (12 and 13).
Write a program to create a Dataframe storing salesmen details (name, zone, sales) of five salesmen.
A list stores three dictionaries each storing details, (old price, new price, change). Write a program to create a dataframe from it.