Ip 123 Questions
Ip 123 Questions
: Time -
Date : MM - 15
(a) Series
(b) DataFrame
Ans : (d)
(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]
Ans : (c)
import numpy as nP
import pandas as pd
L=np.array([10,20])
x=pd,Series(_____) #statement 1
print(x)
0 1000
1 8000
dtype: int64
(a) d=L*3
(b) data=L**3
(c) L*3
(d) [10,20]**3
Ans : (a)
import pandas as pd
s = pd.Series([1,3,5,np.nan,6,8])
print(s)
(b) [NaN, 1, 3, 5, 6, 8]
(c) [1, 3, 5, 6, 8]
(d) [8, 6, 5, 3, 1]
Ans : (a)
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)
(vii) To print the various attributes of the data frame i.e Shape, Dimensions, Columns and number of
records.
(ix) To create another data frame which will store all the records of the teacher whose salary is
greater than 5000.
(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.
(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.
(xxv) To Update the new colum with values as Salary + HRA + Dearness Allowance - Tax
(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.
(i) s2[1:]
(ii) s2[1:]
(iii) s2[::2]
(iv) s2[::-1]
(v) s2[-1]
(vi) s2['feb':'mar']
Ans :