STUDENT
DATA HANDLING USING PANDAS AND DATA VISUALIZATION
Total Q: 82
Time: 70 Mins
Q 1.
Which Matplotlib plot is best suited to represent changes in data over time?
Bar plot
Histogram
Line plot
Histogram & Bar plot
Q 2.
Assertion (A) : In order to be able to use Python's data visualization library, we need to import the pyplot module from matplot library.
Reason (R) : The pyplot module houses a variety of functions required to create and customize charts or graphs.
Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of Assertion (A).
Both Assertion (A) and Reason (R) are true, but Reason (R) is not the correct explanation of Assertion (A).
Assertion (A) is true, but Reason (R) is false.
Assertion (A) is false, but Reason (R) is true.
Q 3.
Which of the following libraries defines an ndarray in Python?
pandas
numpy
matplotlib
scipy
Q 4.
What will be the output of the following Python code?
import pandas as pd
dd={ 'One' :1, 'Two' :2, 'Three' :3, 'Seven' :7}
rr=pd.Series(dd)
rr ['Four'] =4
print(rr)
Q 5.
Assertion (A): We can add a new column in an existing DataFrame.
Reason (R): DataFrames are size mutable.
Both Assertion (A) and Reason (R) are true, and Reason (R) is the correct explanation of Assertion (A)
Both Assertion (A) and Reason (R) are true, but Reason (R) is not the correct explanation of Assertion (A)
Assertion (A) is True, but Reason (R) is False
Assertion (A) is False, but Reason (R) is True
Q 6.
Which of the following Python statements is used to change a column label in a DataFrame, df?
df = df.rename({old_name : new_name}, axis='columns')
df = df.rename(old_name, new_name, axis='columns')
df = df.change_name(old_name, new_name, axis='bar')
df = df.update({old_name : new_name}, axis='bar')
Q 7.
Pandas is a:
Package
Language
Library
Software
Q 8.
Out of the following, which function cannot be used for customization of charts in Python?
xlabel()
title()
legend()
colour()
Q 9.
Using Python Matplotlib _________ can be used to count how many values fall into each interval
line plot
bar graph
histogram
none of these
Q 10.
The following code creates a dataframe named 'df1' with ______________ columns.
import pandas as pd
ls1=[{'a':10, 'b':20, 'c':30, 'd':40},{'a':5, 'b':10, 'c':20}]
df1 = pd.DataFrame(ls1)
1
2
3
4
Q 11.
Which of the following command will not show first five rows from the Pandas series named S1 ?
S1[0: 5]
S1.head()
S1.head(5)
S1.head[0:5]
Q 12.
In Pandas library of Python, a one-dimensional array containing a sequence of values of any datatype is known as :
DataFrame
Histogram
Series
Panel
Q 13.
The command to install the pandas is:
install pip pandas
install pandas
pip pandas
pip install pandas
Q 14.
Fill in the Blank:
When we create Dataframe from list of dictionaries, then number of columns in DataFrame is equal to the ____________ .
maximum number of keys in first dictionary of the list.
maximum number of different keys in all dictionaries of the list.
maximum number of dictionaries in the list.
None of these
Q 15.
CSV stands for:
Column Separated Value
Class Separated Value
Comma Separated Value
None of these
Q 16.
Which command will be used to delete 3rd and 5th rows of the data frame. Assuming the data frame name as DF, with default indexes.
DF.drop([2,4],axis=0)
DF.drop([2,4],axis=1)
DF.drop([3,5],axis=1)
DF.drop([3,5])
Q 17.
The command used to give a heading to a graph is _________
plt.show()
plt.plot()
plt.xlabel()
plt.title()
Q 18.
By default, the plot() function of Matplotlib draws a ______ plot.
histogram
column
bar
line
Q 19.
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
Q 20.
Which one of the following is an attribute of the series in Pandas to set the index label for the given object?
label
index
loc
All of the above
Q 21.
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
Q 22.
Assertion (A) : A Series is a one dimensional array and a DataFrame is a two-dimensional array containing sequence of values of any data type. (int, float, list, string, etc.)
Reason (R) : Both Series and DataFrames have by default numenc indexes starting from zero.
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 and (R) is false.
(A) is false but (R) is true.
Q 23.
Which of the following Python statements will be used to select a specific element having index as points, from a Pandas Series named ser?
ser.element(points)
ser.select(points)
ser[points]
ser.show[points]
Q 24.
Using Python Matplotlib __________ can be used to display information as a series of data points.
line chart
bar graph
histogram
None of the above
Q 25.
State whether the following statement is True or False:
The column name of a DataFrame must be unique.
True
False
-
-
Q 26.
Method or function to add a new row in a data frame is:
.loc[ ]
.iloc[ ]
join
add()
Q 27.
What is the default index type for a Pandas Series if not explicitly specified?
String
List
Numeric
Boolean
Q 28.
What will be the output of the following Pythan code ?
import pandas as pd
dd={'Jan':31,'Feb':28,'Mar':31,'Apr':30}
rr=pd.Series(dd)
print(rr)
Q 29.
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)
Q 30.
Fill in the Blank:
When we create Dataframe from dictionary of Series, then number of columns in DataFrame is equal to the ___________ .
Number indexes in the Series
Number of keys in the dictionary
Maximum number data values in the series
None of these
Q 31.
While creating a Series using a dictionary, the keys of the dictionary become:
Values of the Series
Indices of the Series
Data type of the Series
Name of the Series
Q 32.
In a DataFrame, Axis= 1 represents the_____________ elements.
Indexes
Rows
Columns
Attributes
Q 33.
Which of the following can be used to specify the data while creating a DataFrame?
Series
List of Dictionaries
Structured ndarray
All of these
Q 34.
Which Python package is used for 2D graphics ?
matplotlib.pyplot
pyplot.lib
matplotlib.py
matplotlib.plt
Q 35.
Assertion (A):- DataFrame has both a row and column index.
Reasoning (R): - A DataFrame is a two-dimensional labelled data structure like a table of MySQL.
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
Q 36.
Which of the following Python statements is used to import data from a CSV file into a Pandas DataFrame (Note: pd is an alias for pandas)?
pd.open_csv('filename.csv')
pd.read_csv('filename.csv')
pd.load_csv('filename.csv')
pd.import_csv('filename.csv')
Q 37.
State whether the following statement is True or False:
Slicing can be used to extract a specific portion from a Pandas Series.
True
False
-
-
Q 38.
Assertion (A) : The Pandas library in Python is primarily used for creating static, animated and interactive 2D plots or figures.
Reason (R) : Data visualization can be achieved with the help of a variety of charts and plots, including static plots, animations, and interactive visualizations.
Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of Assertion (A).
Both Assertion (A) and Reason (R) are true, but Reason (R) is not the correct explanation of Assertion (A).
Assertion (A) is true, but Reason (R) is false.
Assertion (A) is false, but Reason (R) is true.
Q 39.
While accessing the column from the data frame, we can specify the column name. In case column does not exist, which type of error it will raise:
Key Error
Syntax Error
Name Error
Runtime Error
Q 40.
Which function will be used to read data from a CSV file into pandas data frame?
readcsv()
to_csv()
read_csv()
csv_read()
Q 41.
What will be the output of the following program ?
import pandas as pd
x=6
S1=pd.Series(x,index=[1,2,4,6,8,9])
print(S1)
None of these
Q 42.
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
Q 43.
Ritika is a new learner for the python pandas, and she is aware of some concepts of python. She has created some lists, but is unable to create the data frame from the same. Help her by identifying the statement which will create the data frame.
import pandas as pd
Name=['Manpreet','Kavil','Manu','Ria']
Phy=[70,60,76,89]
Chem=[30,70,50,65]
df=pd.DataFrame({"Name":Name,"Phy":Phy,"Chem":Chem})
d=("Name":Name,"Phy":Phy,"Chem":Chem)
df=pd.DataFrame(d)
df=pd.DataFrame([Name,Phy,Chem],columns=['Name',"Phy","Chem","Total"])
df=pd.DataFrame({Name:"Name", Phy :"Phy",Chem: "Chem"})
Q 44.
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)
Q 45.
Which of the following is NOT true with respect to CSV files?
Values are separated by commas.
to_csv () can be used to save a dataframe to a CSV file.
CSV file is created using a powerpoint.
CSV file is a type of text file.
Q 46.
In a Pandas DataFrame, if the tail() function is used without specifying the optional argument indicating the number of rows to display, what is the default number of rows displayed, considering the DataFrame has 10 entries?
0
1
4
5
Q 47.
In Python which function of matplotlib library is used to save a plot?
save()
saveplot()
export()
savefig()
Q 48.
What will be the output of the Python program ?
import pandas as pd
I=['Apple','Banana','Mango','Orange','Litchi']
df=pd.DataFrame(I,index=[1,2,3,4,5])
print(df.iloc[1:3])
Q 49.
Which of the following command is used to display first ten rows of a DataFrame 'DF' ?
DF.head()
DF.header()
DF.head(10)
DF.Head(10)
Q 50.
Given the following Series S1 and S2:
Write the command to find the sum of series S1 and S2
print(S1.sum(S2))
print(S1 + S2)
print(sum(S1,S2))
print(add(S1, S2))
Q 51.
The name "Pandas" is derived from the term:
Panel Data
Panel Series
Python Document
Panel Data Frame
Q 52.
State whether the following statement is True or False: The index of a Series must be unique.
True
False
-
-
Q 53.
Write the output of the given command:
df1.loc[:0,'Sal']
Consider the given dataframe.
0 Kavita 50000 3000
50000
3000
55000
Q 54.
Pandas Series is:
2 Dimensional
3 Dimensional
1 Dimensional
Multidimensional
Q 55.
Assertion (A): The drop() method in Pandas can be used to delete rows and columns from a DataFrame.
Reason (R): The axis parameter in the drop() method specifies whether to delete rows (axis=0) or columns (axis=1).
Both Assertion (A) and Reason (R) are True and Reason (R) is the correct explanation for Assertion (A).
Both Assertion (A) and Reason (R) are True and Reason (R) is not the correct explanation for Assertion (A).
Assertion (A) is True and Reason (R) is False.
Assertion (A) is False, but Reason (R) is True.
Q 56.
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
Q 57.
Assertion (A): In Dataframe, using rename function we can change the name of multiple columns using single statement.
Reason (R): In rename, axis=0 argument is mandatory for changing the column names.
Both Assertion (A) and Reason (R) are true, and Reason (R) is the correct explanation of Assertion(A)
Both Assertion (A) and Reason (R) are true, but Reason (R) is not the correct explanation of Assertion (A)
Assertion (A) is True, but Reason (R) is False
Assertion (A) is False, but Reason (R) is True
Q 58.
In Python Pandas, DataFrame._____[] is used for label indexing with DataFrames.
label
index
labindex
loc
Q 59.
Fill in the Blank
Boolean indexing in Pandas DataFrame can be used for _______.
Creating a new DataFrame
Sorting data based on index labels
Joining data using labels
Filtering data based on condition
Q 60.
State whether the following statement is True or False:
We can add a row in DataFrame using iloc.
True
False
-
-
Q 61.
State whether the following statement is True or False:
The index of a DataFrame must be unique.
True
False
-
-
Q 62.
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])
Q 63.
Statement A: To make a Histogram with Matplotlib, we can use the plt.hist() function.
Statement B: The bin parameter is compulsory to create histogram.
Statement A is correct
Statement B is correct
Statement A is correct, but Statement B is incorrect
Statement A is incorrect, but Statement B is correct
Q 64.
_____________ is the function to save the graph.
Savefig()
Savefigure()
Savegraph()
Savechart()
Q 65.
Function to display the first n rows in the DataFrame:
tail (n)
head (n)
top (n)
first (n)
Q 66.
We can analyse the data in pandas with
Series
Data Frame
Both Series and DataFrame
None of these
Q 67.
What will be the output of the Python program mentioned below ?
import pandas as pd
df=pd.DataFrame(['Apple','Banana','Orange','Grapes','Guava'])
print(df[2:4:2])
Q 68.
State whether the following statement is True or False:
In Python, we cannot create an empty DataFrame.
True
False
-
-
Q 69.
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 these
Q 70.
Consider the following data frame name df
Write the output of the given command:
print(df.marks/2)
Q 71.
Python pandas was developed by:
Guido van Rossum
Travis Oliphant
Wes McKinney
Brendan Eich
Q 72.
To display last five rows of a series object 'S', you may write:
S.Head()
S.Tail(5)
S.Head(5)
S.tail()
Q 73.
Which of the following data structure is used for storing one-dimensional labelled data in Python Pandas?
Integer
Dictionary
Series
DataFrame
Q 74.
On the basis of the dataframe DF, which command will delete the row of science marks?
DF.drop('Science', axis=1)
DF.drop('Science', axis=0)
DF.drop('Science', axis=-1)
DF.drop('Science', axis==0)
Q 75.
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
Q 76.
Observe the following figure. Identify the coding for obtaining this as output.
import matplotlib.pyplot as plt
plt.plot([1,2],[4,5])
plt.show()
import matplotlib.pyplot as plt
plt.plot([1,2,3],[4,5,1])
plt.show()
import matplotlib.pyplot as plt
plt.plot([2,3],[5,1])
plt.show()
import matplotlib.pyplot as plt
plt.plot([1,3],[4,1])
plt.show()
Q 77.
What is the minimum number of arguments required for plot() function in matplotlib?
1
2
3
4
Q 78.
Which of the following Python statements can be used to select a column column_name from a DataFrame df ?
df.getcolumn('column_name')
df['column_name']
df.select('column_name')
df(column_name)
Q 79.
What is a correct syntax to return the values of first row of a Pandas DataFrame?
Assuming the name of the DataFrame is dfRent.
dfRent[0]
dfRent.loc[1]
dfRent.loc[0]
dfRent.iloc[1]
Q 80.
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
Q 81.
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=['Qutub Minar','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)
Q 82.
On the basis of the dataframe DF, which command will add a new column with name of student 'Prem' in the dataframe
DF['Prem']=[89,78,76]
df['Prem']=[89,78,76]
DF['Prem']=[89,78,76,67]
DF['Name']=[89,78,76]