KnowledgeBoat Logo
|

Informatics Practices

What will be the output of the following program ?

import pandas as pd
dic = {'Name' : ['Sapna', 'Anmol', 'Rishul', 'Sameep'], 'Agg' : [56, 67, 75, 76], 'Age' : [16, 18, 16, 19]}
df = pd.DataFrame(dic, columns = ['Name', 'Age'])
print(df)

(a)

    Name   Agg Age
101 Sapna  56  16
102 Anmol  67  18
103 Rishul 75  16
104 Sameep 76  19

(b)

    Name   Agg   Age
0   Sapna  56    16
1   Anmol  67    18
2   Rishul  75   16
3   Sameep  76   19

(c)

    Name 
0   Sapna 
1   Anmol 
2   Rishul
3   Sameep 

(d)

    Name   Age
0   Sapna  16
1   Anmol  18
2   Rishul  16
3   Sameep  19

Python Pandas

4 Likes

Answer

(d)

     Name  Age
0   Sapna   16
1    Amol   18
2  Rishul   16
3  Sameep   19

Working

The code creates a DataFrame df with columns 'Name' and 'Age' using a dictionary. It contains data about individual's names and ages. The DataFrame is then printed, displaying the specified columns.

Answered By

3 Likes


Related Questions