Font size
WorksheetsCBSE Python Series Questions
Total questions: 66
Worksheet time: 2hrs 43mins
A Series is a one dimensional array containing a sequence of values of any data type (int, float, list, string, etc), having by default have ________ data labels.
alphanumeric
string
decimal
numeric
Find the output of the following code: import pandas as pd lst1=[20,35,40] ser1=pd.Series([20,35,40]) print(lst1+lst1) print(ser1+ser1)
Complete the given Python code to get the required output as "California": import_____________as pd data={'Yosemite':'California','Yellowstone':'Wyoming','Glacier':'Montana','RockyMountain':'Colorado'} national_parks=pd.Series(_____________) print(national_parks _________)
Which of the following command will show the last 3 rows from a Pandas Series named NP?
NP.Tail( )
NP.tail(3)
NP.TAIL(3)
All of the above
In Python Pandas, while performing mathematical operations on series, index matching is implemented and all missing values are filled in with _____by default.
Null
Blank
NaN
Zero
Assertion (A):- To use the Pandas library in a Python program, one must import it. Reasoning (R): - The only alias name that can be used with the Pandas library is pd.
Both A and R are true and R is the correct explanation for A
Both A and R are true and R is not the correct explanation for A
A is True but R is False
A is false but R is True
Predict the output of the given Python code: import pandas as pd list1=[-10,-20,-30] ser = pd.Series(list1*2) print(ser)
Complete the given Python code to get the required output as: Rajasthan import _________ as pd di = {'Corbett': 'Uttarakhand', 'Sariska': 'Rajasthan','Kanha': 'Madhya Pradesh', 'Gir':'Gujarat'} NP = ___________. Series ( _____ ) print(NP[ ___________ ])
Which of the following is a one-dimensional array containing a sequence of values in Python ?
Relation
DataFrame
Series
Square
In Python Pandas, head(n) method returns the first n members of the series.What is the default value of n?
2
3
4
5
What will be the output of the following code ? import pandas as pd S1=pd.Series(data=[1,7]) S2=pd.Series(S1+S1) print(S2)
Write a program in Python Pandas to create a series "car" from the following Dictionary : dic={"Model":["Samurai","Accord","CR-V","Nexon"],"Brand":["Suzuki","Honda","Honda","Tata"],"Make":[1993,1997,1997,2021]}
What will be the output of the following code? import pandas as pd myser=pd.Series([0, 0, 0]) print(myser)
0 0
0 1 0 0
0 0 1 0 2 0
0 0 1 1 2 2
Assertion (A) : The output of addition of two series will by NAN, if one of the elements or both the elements have no value(s). Reason (R): While performing mathematical operations on a series, by default all missing values are filled in with 0.
(A) is true but (R) is false
(A) is false but (R) is true
Write a Python program to create a series object, country using a list that stores the capital of each country. Note: Assume four countries to be used as index of the series object are India, UK, Denmark, and Thailand having their capitals as New Delhi, London, Copenhagen, and Bangkok respectively.
What will be the output of the following code: import pandas as pd s1=pd.Series(data=2*(3,10)) print(s1)
To display last five rows of a series object 'S', you may write:
S.Head()
S.Tail(5)
S.Head(5)
S.tail()
Which of the following statement will import pandas library?
Import pandas as pd
import Pandas as py
import pandas as pd
import panda as pd
Write a program to create a series object using a dictionary that stores the number of students in each house of class 12D of your school. Note: Assume four house names are Beas, Chenab, Ravi and Satluj having 18, 2, 20, 18 students respectively and pandas library has been imported as pd.
What will be the output of the following code: >>>import pandas as pd >>>A=pd.Series(data=[35,45,55,40]) >>>print(A>45)
Which of the following statement is wrong?
Can't change the index of the Series
We can easily convert the list, tuple and dictionary into a series
A Series represents a single column in memory
We can create empty Series
What type of error is returned by the following statement? import pandas as pa pa.Series([1,2,3,4], index=['a','b','c'])
Value Error
Syntax Error
Name Error
Logical Error
Which is incorrect statement for the python package Numpy?
It is a general purpose array processing package.
Numpy arrays are faster and more compact
It is multi-dimensional arrays
It is proprietary software
The data of any CSV file can be shown in which of the following software?
The data of any CSV file can be shown in which of the following software?
MS Word
Notepad
Spreadsheet
All of the above
Which python library is not used for data science?
Panda
Numpy
Matplotlib
Tkinter
What is the correct statement for the above output in the following statement 1?
d=L*3
data=L**3
L*3
[10,20]**3
Which attribute is used with Series to count the total number of NaN values (non NaN values)?
size
len
count
count total
Which statement will display all odd values?
print(data%2= =0)
print(data(data%2!=0)
print(data mod 2!=0)
print(data[data%3=0])
What will be the output of the following code?
0 False 1 True 2 False 3 True 4 False 5 False dtype:bool
1 54 3 89 dtype:int64.
0 31 1 54 2 34 3 89 4 12 5 23 dtype:int64
1 True 3 True dtype:bool
Consider the following series ser=pd.Series(['C','O','M','F','O','R','T','A','B','L','E'], index=[1,2,3,4,5,6,7,8,9,10,11]) print(ser[4: ])
4 F 5 O 6 R 7 T 8 A 9 B 10 L 11 E dtype:object
4 F 5 O 6 R 7 T 8 A dtype:object
4 F 5 O 6 R 7 T 8 A 9 B dtype:object
5 O 6 R 7 T 8 A 9 B 10 L 11 E dtype:object
Consider the following code: import pandas as pd S1=pd.Series([23,24,35,56],index=['a','b','c','d']) S2=pd.Series([27,12,14,15],index=['b','y','c','ab']) df=pd.DataFrame(S1+S2) print(df) Output for the above code will be:
0 a NaN ab NaN b 51.0 c 49.0 d NaN y NaN
0 a 50 b 36 c 49 d 71
0 b 50 y 36 c 49 ab 71
0 a NaN ab NaN b NaN c NaN d NaN y NaN
The name 'Pandas' is derived from the term:
Panel Data
Panel Series
Python Document
Panel Data Frame
The command to install the pandas is:
install pip pandas
install pandas
pip pandas
pip install pandas
Python pandas was developed by:
Guido van Rossum
Travis Oliphant
Wes McKinney
Brendan Eich
Pandas Series is:
2 Dimensional
3 Dimensional
1 Dimensional
Multidimensional
Pandas is a:
Package
Language
Library
Software
We can analyse the data in pandas with
Series
Data Frame
Both of the above
None of the above
Which of the following import statement is not correct?
import pandas as class12
import pandas as 1pd
import pandas as pd1
import pandas as pd
What will be the output of the given code? import pandas as pd s = pd.Series([1,2,3,4,5], index=['akram', 'brijesh','charu','deepika','era']) print(s['charu'])
1
2
3
4
Assuming the given series, named stud, which command will be used to print 5 as output?
stud.index
stud.length
stud.values
stud.size
A social science teacher wants to use a pandas series to teach about Indian historical monuments and its states. The series should have the monument names as values and state names as indexes which are stored in the given lists, as shown in the code. Choose the statement which will create the series: import pandas as pd Monument=['QutubMinar','Gateway of India', 'Red Fort','Taj Mahal'] State=['Delhi','Maharashtra','Delhi', 'Uttar Pradesh']
S=df.Series(Monument,index=State)
S=pd.Series(State,Monument)
S=pd.Series(Monument,index=State)
S=pd.series(Monument,index=State)
Consider the following series named animal: L Lion B Bear E Elephant T Tiger W Wolf dtype:object Write the output of the command: print(animal[::-3])
L Lion T Tiger dtype:object
B Bear E Elephant dtype:object
W Wolf B Bear dtype:object
W Wolf T Tiger dtype:object
Write the output of the given program: import pandas as pd S1=pd.Series([5,6,7,8,10],index=['v','w','x','y','z']) l=[2,6,1,4,6] S2=pd.Series(l,index=['z','y','a','w','v']) print(S1-S2)
a 0 v -1.0 w 2.0 x NaN y 2.0 z 8.0 dtype: float64
a NaN v -1.0 w 2.0 x NaN y 2.0 z 8.0 dtype: float64
v -1.0 w 2.0 y 2.0 z 8.0 dtype: float64
a NaN v -1.0 w 2.0 x 3.0 y 2.0 z 8.0 dtype: float64
Write the output of the given command: import pandas as pd s=pd.Series([1,2,3,4,5,6],index=['A','B','C','D','E','F']) print(s[s%2= =0])
B 0 D 0 F 0 dtype: int64
A 1 B 2 C 5 dtype: int64
B 2 D 4 F 6 dtype: int64
B 1 D 2 F 3 dtype: int64
Read the statements given below. Identify the right option from the following for Attribute and method/function. Statement A: Attribute always ends without parenthesis. Statement B: Function/Method cannot work without arguments.
Both statements are correct.
Both statements are incorrect.
Statement A is correct, but Statement B is incorrect
Statement A is incorrect, but Statement B is correct
Series in Pandas to set the index label for the given object?
label
index
loc
All of the above
Write a program in Python to create the series of all the alphabets of 'Happy' with default index. Print the first three alphabets.
Consider the following two series 'A' and 'B': A=pd.Series([2,4,6], index=[0,1,2]) B=pd.Series([1,3,5], index=[1,2,3]) (i) Write the statement to add both the series 'A' and 'B' (ii) Write the statement to multiply two series 'A' and 'B'
Create a series S1 with the values (2,3,1). (a) print(S1**3) (b) print(S1*3)
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))
Given the following Series S1 and S2: Write the command to find the sum of series S1 and S2.
Consider a given Series, M1: Write a program in Python Pandas to create the series.
Consider the following Series object, S_amt (i) Write the command which will display the name of the furniture having rent>250. (ii) Write the command to name the series as Furniture.
Consider two objects x and y. x is a list whereas y is a Series. Both have values 20, 40, 90, 110. What will be the output of the following two statements considering that the above objects have been created already. a. print (x*2) b. print(y*2) Justify your answer.
Find the output of following program: import numpy as np Profits=np.array([1520, 1245, 1345, 1525, 2110, 1020, 1725]) print(Profits[2:5])
Fill in the blank with appropriate numpy method to change the contents of the given 1 dimensional array Val1D into a 2 dimensional array Val2D with 3 rows and 2 columns per row: import numpy as np Val1D=np.array([15,25,35,45,55,65]) Val2D = ____________________________
Write the output of the following Python code: import numpy as np Score1=np.array([90,92,94,96,95]) Score2=np.array([95,90,98,96,92]) S1=(np.where(Score1>Score2)) S2=(np.where(Score2>Score1)) print(Score1[S1], Score2[S2])
Write single line Pandas statements for each of the following. (Assuming necessary modules have been imported): (i) Declare a Pandas series named Packets having dataset as: [125, 92, 104, 92, 85, 116, 87, 90] (ii) Display the median of the elements present in the dataset of Packets using the Pandas method for it.
Write Numpy single line statement for each of the following from (i) to (iii) (i) To create a 3 x 2 array named ARR2D with the following values. (Assuming necessary modules have been imported as np ): (ii) Assign the contents of the above array ARR2D to a new 1D array named ARR1D. (iii) Display content of array ARR1D as follows: [10 20 30 40 50 60]
Write Numpy single line statement for each of the following from (i) to (iii) (i) To create a 4 x 3 array named ARR with the following values. (Assuming necessary modules have been imported as np ): (ii) Topple the contents of the array ARR upside down so that its contents become: (iii) Display the changed content of the array ARR in the following format : [ [100 110 120 ] [ 70 80 90 ] [ 40 50 60 ] [ 10 20 30 ] ]
Find the output of following program: import numpy as np d=np.array([10,20,30,40,50,60,70]) print(d[-4])
Fill in the blank with appropriate numpy method to calculate or the covariance of an array import numpy as np data=np.array([1,2,3,4,5,6]) print(np. (a) (data,ddof=0))
Write the output of the following code : import numpy as np array1=np.array([10,12,14,16,18,20,22]) print(array1[1:5:2])
What is series? Explain with the help of an example.
Write a code in Python to search for a given value in a list of elements(Without using in-built function) Example: If the List contains: [20,30,40,50,60,80,120] and the element to be searched is:60 Then the output should be: Found at position 4 OR Write a code in python to find the minimum value in a list. Example: If the List contains: [100,150,90,65,180,200] Then the output should be: Minimum Value is 65
