0% found this document useful (0 votes)
11 views4 pages

Revision Test

The document contains a series of multiple-choice questions and open-ended questions related to data handling using the Pandas library in Python. It covers various functions, methods, and concepts such as DataFrame, Series, and CSV files. The questions assess knowledge on creating, manipulating, and accessing data within Pandas.

Uploaded by

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

Revision Test

The document contains a series of multiple-choice questions and open-ended questions related to data handling using the Pandas library in Python. It covers various functions, methods, and concepts such as DataFrame, Series, and CSV files. The questions assess knowledge on creating, manipulating, and accessing data within Pandas.

Uploaded by

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

Revision – Test

Chapter – 1 (Data Handling Using Pandas – I)


Multiple Choice Questions:
Q.1 head( ) function is used to return first………..rows.
a) n–1 b) n+1
c) n2 d) 2
Q.2 Which function is used to sort the series values using values?
a) sort ( ) b) values ( )
c) sort_values ( ) d) values_sort ( )
Q.3 The columns of DataFrame can be:
a) Heterogeneous b) Homogeneous
c) Both (a) & (b) d) None of these
Q.4 loc takes two single operators separated by
a) dot (.) b) semicolon(;)
c) colon(:) d) comma(,)
Q.5 Which function is used to delete a row from DataFrame?
a) del( ) b) drop( )
c) delete( ) d) dropcol( )
Q.6 In Boolean indexing………………can be used to filter the data.
a) Boolean vectors b) Boolean column
c) Boolean mapper d) Boolean label
Q.7 The full form of CSV is:
a) Comma Separate Value b) Comma Separated Values
c) Common Separated Values d) None of these
Q.8 Which of the following is/are library function(s) used to load data from CSV files
into DataFrame?
a) read_csv( ) b) to_csv( )
c) Both (a) & (b) d) None of these
Q.9 The name “Pandas” is derived from the term:
a) Panel Data b) Panel Series
c) Python Document d) Panel Data Frame
Q.10 Method or Function to add a new row in a dataframe is:
a) .loc( ) b) .iloc( )
c) join( ) d) add( )
Q.11 Which of the following import statement is not correct?
a) import pandas as clas b) import pandas as 1pd
c) import pandas as pd1 d) import pandas as pd
Q.12 Whicle accessing the column from the dataframe, we can specify the column
name. in case column does not exist, which type of error it will raise?
a) Key Error b) Syntax Error
c) Name Error d) Runtime Error
Q.13 Function to display the first n rows in the DataFrame is:
a) tail(n) b) head(n)
c) top(n) d) first(n)
Q.14 Which function will be used to read data from a CSV file into Pandas dataframe?
a) readcsv( ) b) to_csv( )
c) read_csv( ) d) csv_read( )
Q.15 Which os the following is not an attribute of Pandas dataframe?
a) length b) T
c) size d) shape
Q.16 What will be the output of the given code?
import pandas as pd
s= pd.Series([1,2,3,4,5], index = [‘Ram’, ‘Shyam’, ‘Mukesh’, ‘Charu’, Deepika])
print(s[‘Mukesh’])
a) 1 b) 2
c) 3 d) 4
Q.17 What is a correct syntax to return the values of first row of Pandas DataFrame?
Assuming the name of the DataFrame is dfRent.
a) dfRent[0] b) dfRent.loc[1]
c) dfRent.loc[0] d) dfRent.iloc[1]
Answer the following questions:
Q.18 How can you create an empty series?
Q.19 What is the use of index number in Series?
Q.20 Write the syntax to sort the series values using indexes in descending order.
Q.21 How can you create a DataFrame?
Q.22 Write the output of the following code:
import pandas as pd
data = pd.DataFrame( )
print(data)
Q.23 How can you select a single column?
Q.24 Write a code to create a series object using a dictionary that stores the salary of
employees in ABC organization.
Q.25 How to access multiple columns in DataFrame?
Q.26 Write statement to print elements within a range:
Q.27 Write a Python code to create a DataFrame with appropriate headings from the
list given below:
[‘S101’, ‘Amy’, 70], [‘S102’, ‘Bandhi’, 69], [‘S104’, ‘Cathy’, 75], [‘S105’, ‘Gundaho’,
82]
Q.28 Write a small Python code to create a DataFrame with headings (a & b) from the
list given below:
[[10, 20], [30, 40], [50, 60], [70, 80]]
Q.29 Write the output of the following code:
import pandas as pd
in = [1, 2, 3, 4, 5]
data1 = [‘a’, ‘b’, ‘c’, ‘d’, ‘e’]
a= pd.Series(data = in, index = data1, dtype = np.float64)
print (a)
Q.30 Give the output of the following statements based on given code:
import pandas as pd
import numpy as np
data = np.array([‘E’, ‘N’, ‘V’, ‘I’, ‘R’, ‘O’, ‘N’, ‘M’, ‘E’, ‘N’, ‘T’])
a = pd.Series(data)
i) a[ : -5] ii) a[3 : 7]
Q.31 Write the output of the following code:
import pandas as pd
data = [‘a’ : pd.Series([20, 85, 46, 23, 56], index = [1, 2, 3, 4, 5]),
‘b’ : pd.Series([33, 45, 57, 12, 34, 82, 49], index = [1, 2, 3, 4, 5, 6, 7])]
df = pd.DataFrame(data)
print (df)
Q.32 Write a Pandas program to convert a dictionary to a Pandas series.
Q.33 Consider the series object sr1 that stores the salary of teacher, as shown below.
Here Teacher’s name represents by their initial names.
R 15000
K 12000
N 20000
L 22000
Write the code to modify the salary of K as 18000 and for N and L as 25000. Print
the changed Series.
Q.34 Write the output of the following code, considering the Series sr as given below.
0 Computer
1 Maths
2 Science
3 English
4 Hindi
5 Social Science
i) print(sr[3 : 5]) ii) print(sr.index)
iii) print(sr.values) iv) print(sr[0 : 2])
Q.35 Give an example to create a DataFrame from dictionary of Series.

You might also like