Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Pandas

Total questions: 17

Worksheet time: 17mins

Name
Class
Date
1.

What method is used to read a CSV file using pandas?

a)
b)

pandas.load_csv()

c)
d)

pandas.get_csv()

2.

Which of the following will return the number of non-null entries in each column?

a)

df.size

b)

df.shape

c)

df.count()

d)

df.columns

3.

What is the output of df.shape?

a)

List of (columns, rows)

b)

List of (rows, columns)

c)

Tuple of (rows, columns)

d)

Tuple of (columns, rows)

4.

How can you check for missing values in a DataFrame?

a)

df.empty()

b)

df.find_nulls()

c)

df.missing()

d)

df.isnull()

5.

Which function is used to drop rows with missing values?

a)

df.remove_na()

b)

df.delete()

c)

df.dropna()

d)

df.clean_null()

6.

How to fill missing values with zero?

a)

df.nulls(0)

b)

df.insertna(0)

c)

df.fillna(0)

d)

df.replace_null(0)

7.

Which method is used to reset the index of a DataFrame?

a)

df.reindex()

b)

df.reset_index()

c)

df.set_index(None)

d)

df.index_reset()

8.

What should be the axis value for df.drop() when dropping a column?

a)

0

b)

1

c)

-1

d)

2

9.

What does df[df['Age'] > 25] do?

a)

Filter all rows where Age is less than 25

b)

Return Age column where Age is greater then 25

c)

Filter rows where Age is greater than 25

d)

Returns all rows

10.

What does df.groupby('Department') do?

a)

Sorts the DataFrame

b)

Groups the DataFrame by 'Department' column

c)

Filters the DataFrame

d)

Filter the Department column

11.

What is the default merge type in pd.merge()?

a)

outer

b)

inner

c)

left

d)

right

12.

How to rename column names in pandas?

a)

df.changename(columns={'old':'new'})

b)

df.rename(columns={'old':'new'})

c)

df.retitle()

d)

df.setname()

13.

How can we sort a DataFrame by a column named 'Salary'?

a)

df.sort_values('Salary')

b)

df.sort('Salary')

c)

df.order_by('Salary')

d)

df.sorted('Salary')

14.

What is the difference between iloc[] and loc[]?

a)

iloc[] uses index positions, loc[] uses labels

b)

iloc[] uses labels, loc[] uses positions

c)

loc[] is faster than iloc[]

d)

Both are the same

15.

What does df.duplicated(subset=['A'], keep=False) do?

a)

Returns True for all duplicated values in all columns

b)

Returns True for all duplicate rows in column 'A'

c)

Returns True for only first occurrence

d)

Removes duplicate values

16.

What does the drop_duplicates(keep=False) do?

a)

Keeps all duplicates

b)

Drops all instances of duplicates

c)

Keeps first duplicate only

d)

Keeps last duplicate only

17.

Which operation is faster for large datasets: df.loc[] or df.iloc[]?

a)

loc

b)

iloc

c)

Both are same

d)

Depends on dtype