0% found this document useful (0 votes)
15 views6 pages

Ip 123 Questions

Uploaded by

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

Ip 123 Questions

Uploaded by

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

Roll No.

: Time -
Date : MM - 15

1. Which of the following can be used to make a Dataframe? 1

(a) Series

(b) DataFrame

(c) Structured ndarray

(d) All the above

Ans : (d)

2. Write the statements to answer the given questions: 1

(i) Create the Series of the above dictionary.

(ii) To print the index.

Ans : (i) sports = pd.Series(sportsDict)

(ii) sports.index

3. Identify the correct option to select first four rows and second to fourth columns from a 1
DataFrame ‘Data’. [CBSE 2021]

(a) display(Data.iloc[l : 4, 2 : 4])

(b) display(Data.iloc[l : 5, 2 : 5])

(c) print(Data.iloc(0 : 4, 1: 4])

(d) print(Data.iloc[l : 4, 2.4])

Ans : (c)

4. Consider the following code: [CBSE 2021] 1

import numpy as nP

import pandas as pd

L=np.array([10,20])
x=pd,Series(_____) #statement 1

print(x)

output of the above code is:

0 1000

1 8000

dtype: int64

What is the correct statement for the ab statement-1 ?

(a) d=L*3

(b) data=L**3

(c) L*3

(d) [10,20]**3

Ans : (a)

5. What is the output of the following code? 1

import pandas as pd

s = pd.Series([1,3,5,np.nan,6,8])

print(s)

(a) [1, 3, 5, NaN, 6, 8]

(b) [NaN, 1, 3, 5, 6, 8]

(c) [1, 3, 5, 6, 8]

(d) [8, 6, 5, 3, 1]

Ans : (a)

6. What is the output of the following code? 1

import pandas as pd

s = pd.Series([1,2,3,4,5], index=['a','b','c','d','e'])

print(s['c'])

(a) 3

(b) 'c'

(c) Error

(d) None

Ans : (a)

Answer the following questions based on dataset given below: 4


TNO Tname Tadd Salary
0 T01 Amit 123 Paschim Vihar 23000
1 T02 Rajesh 6/11 Ramesh Nagar 34000
2 T03 Binny 5 West Punjabhi Bagh 12000
3 T04 Charu 23Malviya Nagar 45000
4 T05 Meenakshi 19 Meera Bagh 34000

(i) To write the statement to import the required library.

(ii) To create the data frame from the above dictionary.

(iii) To print the data frame.

(iv) To print the name columns.

(v) To print the complete information of the data frame.

(vi) To print the index of data frame.

(vii) To print the various attributes of the data frame i.e Shape, Dimensions, Columns and number of
records.

(viii) To print the records whose salary is greater than 5000.

(ix) To create another data frame which will store all the records of the teacher whose salary is
greater than 5000.

(x) To display the Salary.

(xi) To set the index to the column 'Tname'.

(xii) To display the record of 'Amit'.

(xiii) To display the record fo 'Amit' and 'Binny'

(xiv) To display the Salary and Address of 'Amit' and 'Binny'.

(xv) To display the records of the teachers whos are earning salary more than 10000.

(xvi) To display the records of the teachers whos are earning salary less than 40000.

(xvii) To add new column Dearness Allowance with any values.

(xviii) To add new column "HRA" using .loc().

(xix) To add new column tax using assign().

(xx) To display the HRA column.

(xxi) To display the records of the Teachers who have HRA of more than 500.

(xxii) To add a new column Total Salary which is to be calculated as Salary + HRA - Tax.

(xxiii) To fill all NaN values with 5000.

(xxiv) To replace all the NaN with space.

(xxv) To Update the new colum with values as Salary + HRA + Dearness Allowance - Tax

Write the output of the given commands:


Ans :
Write the statements to create the Series and answer the questions below: 5

(a) To create 2 Lists i.e. First list is Month list which will store month name and another series day which will store the number of
days in a month.

(b) To print the first 5 records from the Series.

(c) To print the last 2 records.

(d) To print the output of the commands:

(i) s2[1:]

(ii) s2[1:]

(iii) s2[::2]

(iv) s2[::-1]

(v) s2[-1]

(vi) s2['feb':'mar']

Ans :

You might also like