Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Pandas Library Questions

Total questions: 20

Worksheet time: 13mins

Name
Class
Date
1.

What is Pandas primarily used for in Python?

a)

Machine Learning

b)

Data Analysis and Manipulation

c)

Web Development

d)

Image Processing

2.

How can you create a new column in a DataFrame in Pandas?

a)

df['new_column'] = value

b)

df.add('new_column', value)

c)

df.new_column(value)

d)

df.insert('new_column', value)

3.

Which command is used to load a CSV file into Pandas?

a)

pd.read_file('data.csv')

b)

pd.load_csv('data.csv')

c)

pd.read_csv('data.csv')

d)

pd.import_csv('data.csv')

4.

How can you display the first 5 rows of a Pandas DataFrame?

a)

df.first()

b)

df.head()

c)

df.top(5)

d)

df.rows(5)

5.

Which method provides a summary of a DataFrame, including count, mean, and standard deviation?

a)

df.summary()

b)

df.describe()

c)

df.info()

d)

df.head()

6.

How can you filter rows where the column ‘Sales’ is greater than 1000?

a)

df.where(Sales > 1000)

b)

df[df['Sales'] > 1000]

c)

df.select(Sales > 1000)

d)

df.query(Sales > 1000)

7.

The function used to handle missing values in a DataFrame is (a)  

Choose from the below words
df.fillna()
df.dropna()
df.replace()
df.isnull()
8.

What does df.groupby('Category').sum() do?

a)

Splits the DataFrame into categories and adds all values for each category

b)

Creates a bar chart

c)

Deletes duplicate categories

d)

Filters the DataFrame for unique values

9.

HHow do you reset the index of a DataFrame in Pandas?

a)

df.index_reset(inplace=True)

b)

df.reindex()

c)

df.index_reset()

d)

df.reset_index()

10.

Which method removes duplicate rows from a DataFrame?

a)

df.remove_duplicates()

b)

df.drop_duplicates()

c)

df.clean_duplicates()

d)

df.delete_duplicates()

11.

Which command is used to display a plot in Matplotlib?

a)

plt.draw()

b)

plt.show()

c)

plt.display()

d)

plt.open()

12.

What is the function of plt.xlabel() in Matplotlib?

a)

Labels the X-axis

b)

Labels the Y-axis

c)

Creates a title

d)

Sets the axis limits

13.

Which function is used to create a bar chart in Matplotlib?

a)

bar()

b)

plot()

c)

scatter()

d)

hist()

14.

How can you change the color of a line in a Matplotlib plot?

a)

Using color='red' inside plt.plot()

b)

Using linecolor='red'

c)

Using set_color('red')

d)

Using colorize='red'

15.

Which function is used to create a scatter plot in Matplotlib?

a)

plt.scatter()

b)

plt.plot()

c)

plt.bar()

d)

plt.pie()

16.

Which method is used to sort a DataFrame by a specific column in Pandas?

a)

df.sort('column')

b)

df.arrange('column')

c)

df.order_by('column')

d)

df.sort_values('column')

17.

How do you add a title to a plot in Matplotlib?

a)

plt.title('Title')

b)

plt.add_title('Title')

c)

plt.set_title('Title')

d)

plt.name('Title')

18.

Which function is used to create a histogram in Matplotlib?

a)

plt.line()

b)

plt.plot()

c)

plt.bar()

d)

plt.hist()

19.

In Matplotlib, which function is used to add labels to the x-axis and y-axis?

a)
set_xlabel() and set_ylabel()
b)

plt.xlabel() and plt.ylabel()

c)
label_x() and label_y()
d)
axis_labels()
20.

Which function in Matplotlib is used to create a line plot?

a)
plot()
b)
draw()
c)
line()
d)
graph()