0% found this document useful (0 votes)
26 views3 pages

Data Frame Worksheet

CLASS XII INFORMATICS PRACTICES WORKSHEET

Uploaded by

kvmducs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views3 pages

Data Frame Worksheet

CLASS XII INFORMATICS PRACTICES WORKSHEET

Uploaded by

kvmducs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

10/08/2022

1. Observe the following dataframe code:


dt=({'Name': ['Akshit','Bharat','Chetan','Dhaval','Gaura ng'], 'InternalMarks':
[18,19,20,18,19], 'AnnualExam': [76,78,80,76,73]})
df=p d.DataFrame(dt)
Which of the following code will print names and Annual marks of students?
a. print(df.loc[:,’Name’:’AnnualExam’])
b. print(df.loc[‘Name’:’AnnualExam’])
c. print(df.loc[:,df.columns!=’InternalMarks’])
d. All of these

2. Nidhi has created dataframe df1 as following. Identify the correct command to
Remove the null value rows.
a. df1.rowdelete()
b. Df1.del(np.nan)
c. Df1.drop(np.nan)
d. df1.dropna()
3. Which of the following statement(s) will give the exact number of values in each
column
of the dataframe df?
i. print(df.count()) ii. print(df.count(0))
iii. print(df.count) iv. print(df.count(axis=’index’))

Choose the correct option:


a. both (i) and (ii)
b. only (ii)
c. (i), (ii) and (iii)
d. (i), (ii) and (iv)

4. Hari wants to add a new column, the scores of APR Grade with the values, ‘ A’, ‘B’, ‘A’,
‘A’, ‘B’ ,to the DataFrame df. Help Hari to choose the command to do so:
a. df.column=[’A’,’B’,’A’,’A’,’B’,’A’]
b. df [‘Grade’]=[’A’,’B’,’A’,’A’,’B’,’A’]
c. df.loc[‘Grade’]= [’A’,’B’,’A’,’A’,’B’,’A’]
d. Both (b) and (c) are correct
5. Consider a dictionay student contains {‘name’:[‘S1,S2,S3],
‘age’:[15,14,13],’gender’:[‘M’,’F’,’M’]} and a list roll_no = [11,12,13]. Identify the
correct code to create the data frame.

a. df=pd.DataFrame(student,index=roll_no)
b. df=pd.DataFrame(dict=student,roll_no)
c. df= pd.DataFrame(student,roll_no)
d. df=pd.DataFrame(student)
6. D1[ : ] = 77 , will set values of a DataFrame ‘D1’ to 77.
a. Only First Row
b. Only First Column
c. All
d. None of the above
7. 5. In given code dataframe ‘D1’ has rows and columns.
import pandas as pd
LoD = [{‘a’:10, ‘b’:20}, {‘a’:5, ‘b’:10, ‘c’:20}, {‘a’:7, ‘d’:10, ‘e’:20}]
D1 = pd.DataFrame(LoD)
a. 3, 3
b. 3, 4
c. 3, 5
d. None of the above
8. Consider the dataframe given below:

i) The teacher needs to know the marks scored by the student with roll number
4.Help her to identify the correct set of statement/s from the given options
a. df1=df[df[‘rollno’]==4]
print(df1)
b. df1=df[rollno==4]
print(df1)
c . df1=df[df.rollno=4]
print(df1)
d. df1=df[df.rollno==4]
print(df1)
ii) Which of the following command will display the column labels of
thedataframe?
i) print(df.columns())
ii) print(df.column())
iii) print(df.column)
iv) print(df.columns
iii) Write down the command to find minimum value along the columns for each row.
a.df.min()
b.df.min(axis=1)
c.df.min(axis=0)
d.df.min(column)
import pandas as pd
iplw = [{2018:'CSK', 2019:'MI', 2020:'MI'}, {2018:8,2019:8,2020:8,2021:8}]
dfipl = pd.DataFrame(iplw,index=['Winner','TeamsPlayed'])
print(dfipl)

You might also like