Q. 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
import numpy as np

d = {"name":'name',"empno":1}
d1 = {"name":'name1',"empno":2}
d2 = {"name":'name2',"empno":3}
d3 = {"name":'name3',"empno":4}
s = pd.DataFrame([d,d1,d2,d3])
print(s)


Output :-

    name  empno
0   name      1
1  name1      2
2  name2      3
3  name3      4

>>>


4 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. Isme to dataframe batana tha why have u used pd.Series then ?

    ReplyDelete
  2. Ek badi list ke ander 4 dictionary bhi toh dal sakte hai na

    ReplyDelete
    Replies
    1. Yes, But we are solving questions of pandas.

      Delete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post