WorksheetsGrade XII-IP Self Evaluation (Python Series)
Total questions: 25
Worksheet time: 25mins
data ={‘a’:10.,’b’:11.,’c’:12.}
s =pd.Series(data)
index values of s is __________
0,1,2
10,11,12
a,b,c
10a,11b,12c
Pandas Series is a
one-dimensional labeled array
two-dimensional labeled array
three-dimensional labeled array
multi-dimensional labeled array
s = pd.Series(20, index=[2, 3, 4, 5,6])
print (s) will print 20 ______times
4
5
6
1
Give the output:
s=pd.Series([10,20,30,40,50],index =[‘a’,’b’,’c’,0,1]
print(s.loc[1])
10
20
40
50
Give the output:
s=pd.Series([10,20,30,40,50],index =[‘a’,’b’,’c’,0,1])
print(s.iloc[1])
10
20
40
50
By default Series.tail() function display last ___ rows.
3
4
5
6
__________ function is used to delete an element from series.
delete
drop
remove
pop
___________ method in Pandas can be used to change the index of rows and columns of a Series or Dataframe
rename()
reindex()
reframe()
None of these
Given a Pandas series called “S”, the command which will display the last 4 rows is ________________
print(S.tail(4))
print(S.Tail(4))
print(S.tails(4))
print(S.Tails(4))
Given a Pandas series called “S”, the command which will delete the 1st row(index value 0) ______________
S.delete(0)
S.drop(0)
S.pop(0)
S.del(0)
Given a Pandas series called Sequences, the command which will display the first 4 rows is _______.
print(Sequences.head(4))
print(Sequences.Head(4))
print(Sequences.heads(4)
print(Sequences.Heads(4))
Command to create empty Series is
s=pd.emptySeires()
s=pd.Series(empty)
s=pd.Series()
s=pd.Series(NaN)
Gurjeet has created a Series S but forgot to give the index values. Choose the command that will be used to give index values
S.newindex=[10,20,30,40,50]
S.index=[10,20,30,40,50]
S.Series(index=[10,20,30,40,50])
S.modifyindex=[10,20,30,40,50]
Command to assign a name for the indexes
S.indexname
S.name.index
S.index.name
S.nameindex
A Series represents ________ column(s) in memory.
Single
Double
Multiple
all of these
Pandas Series is capable of holding ______data type.
only integer
only string
only integer and string
any
Write single line Pandas statement to declare a Pandas series named Packets having tuple dataset as: 125, 92, 104, 92, 85, 116, 87, 90
Packets = pd.Series((125, 92, 104, 92, 85, 116, 87, 90))
Packets = pd.Series([125, 92, 104, 92, 85, 116, 87, 90])
Packets = pd.Series({125, 92, 104, 92, 85, 116, 87, 90})
None of the above
Write python series to print scalar value “10” 5 times
s = pd.Series(10, index=[5])
s = pd.Series(10, index=[10,5])
s = pd.Series(10, index=[10*5])
s = pd.Series(10, index=[11,12,13,14,15)
Write a single line command to create a series by given list C and index values
C=[‘red’,’green’,’blue’] , index values=[‘r’,’g’,’b’]
p=pd.Series(C,index=[‘r’,’g’,’b’])
p=pd.Series(list=C,index=[‘r’,’g’,’b’])
p=pd.Series(C])
p=pd.Series(values=C,index=[‘r’,’g’,’b’])
Aman wants to create the series with the following list and index values. He asked his friends for help and received muliple answers from friends. But one of the answers is incorrect, you have to identify the incorrect answer.
List=[‘Laptop’,’Pendrive’,’Harddisk’]
index values=[‘L’,’P’,’H’]
import pandas as pd
L=[‘Laptop’,’Pendrive’,’Harddisk’]
p=pd.Series(list=L,index=[‘L’,’P’,’H’])
print (p)
import pandas as pd
L=[‘Laptop’,’Pendrive’,’Harddisk’]
p=pd.Series(data=L,index=[‘L’,’P’,’H’])
print (p)
import pandas as pd
L=[‘Laptop’,’Pendrive’,’Harddisk’]
p=pd.Series(L,index=[‘L’,’P’,’H’])
print (p)
import pandas as pd
L=[‘Laptop’,’Pendrive’,’Harddisk’]
p=pd.Series(L,[‘L’,’P’,’H’])
print (p)
Write code to display the sum of M1 and M2
M1
1 67
2 90
3 34
4 56
5 77
M2
1 78
2 95
3 67
4 23
5 45
print (sum(M1,M2))
print(M1+M2)
print(M1.add(M2))
print(M1.sum(M2))
Set the series name “Marks1” of M1 series
M1
1 67
2 90
3 34
4 56
5 77
M2
1 78
2 95
3 67
4 23
5 45
M1.seriesname=”Marks1”
M1.name=”Marks1”
M1.newname=”Marks1”
M1.setname=”Marks1”
A Series S is given below:
101 Harsh
102 Arun
103 Ankur
104 Harpahul
105 Divya
106 Jeet
With reference to the above question, write the answer.
Choose the command that will give the following output
102 Arun
103 Ankur
104 Harpahul
print(S.loc[2:4])
print(S.iloc[1:4])
print(S[1:3])
print(S[102,103,104])
A Series S is given below:
101 Harsh
102 Arun
103 Ankur
104 Harpahul
105 Divya
106 Jeet
With reference to the above question, write the answer.
Write the command which will display the rows having name=”Ankur”
print(S==”Ankur”)
print(S[S.”Ankur”])
print(S[S==”Ankur”])
print(S=’Ankur”)
Select the correct statement
import panda as pd
import pandas as pd
import pd as pandas
import pd as panda
