Pandas Quiz: Test Your Knowledge!

Welcome to The Coding College, where learning meets fun! This quiz is designed to help you evaluate your understanding of Pandas, the powerful Python library for data manipulation and analysis.

Instructions

  • Each question has one or more correct answers.
  • Review your answers at the end to see how you did!

Quiz Questions

1. What does Pandas primarily help with?

A. Image processing
B. Data manipulation and analysis
C. Web development
D. Machine learning

2. Which of the following is used to create a DataFrame?

A. pd.DataFrame()
B. pd.Series()
C. pd.create_frame()
D. pd.DataFrame.from_dict()

3. How do you read a CSV file into a Pandas DataFrame?

A. pd.load_csv("file.csv")
B. pd.read_file("file.csv")
C. pd.read_csv("file.csv")
D. pd.load_file("file.csv")

4. What is the output of the following code?

import pandas as pd
data = {"A": [1, 2, 3], "B": [4, 5, 6]}
df = pd.DataFrame(data)
print(df["A"])

A.

A
1
2
3

B.

1
2
3

C.

0    1
1    2
2    3
Name: A, dtype: int64

D. Error

5. Which method removes duplicate rows from a DataFrame?

A. drop_duplicates()
B. remove_duplicates()
C. delete_duplicates()
D. filter_duplicates()

6. What does the head() method do in Pandas?

A. Displays all rows of the DataFrame.
B. Displays the last 5 rows of the DataFrame.
C. Displays the first 5 rows of the DataFrame.
D. Displays only the column headers.

7. Which method is used to calculate correlation in Pandas?

A. df.correlation()
B. df.calc_corr()
C. df.corr()
D. df.corrcoef()

8. How can you check for missing values in a DataFrame?

A. df.check_missing()
B. df.isnull()
C. df.missing()
D. df.isnan()

9. Which of the following creates a Pandas Series?

A. pd.Series([1, 2, 3])
B. pd.DataFrame([1, 2, 3])
C. pd.Series.from_list([1, 2, 3])
D. pd.Series({"A": 1, "B": 2})

10. What is the default axis for the sum() method in a DataFrame?

A. Rows (axis=0)
B. Columns (axis=1)
C. Both rows and columns
D. It depends on the shape of the DataFrame

Bonus Questions

11. What does df.info() do?

A. Provides the number of rows and columns in the DataFrame.
B. Displays a summary of the DataFrame, including column names, non-null counts, and data types.
C. Prints the first 5 rows of the DataFrame.
D. Shows the DataFrame schema.

12. How do you merge two DataFrames in Pandas?

A. pd.concat()
B. pd.merge()
C. pd.append()
D. All of the above

Answers

1. B

Pandas is primarily used for data manipulation and analysis.

2. A, D

You can create a DataFrame using pd.DataFrame() or pd.DataFrame.from_dict().

3. C

The correct method to read a CSV file is pd.read_csv().

4. C

Pandas returns the column values along with the index and data type.

5. A

The drop_duplicates() method removes duplicate rows.

6. C

The head() method displays the first 5 rows by default.

7. C

The df.corr() method calculates correlation.

8. B

The df.isnull() method checks for missing values.

9. A, D

Pandas Series can be created from lists or dictionaries.

10. A

By default, the sum() method operates along rows (axis=0).

11. B

df.info() provides a summary of the DataFrame.

12. D

All listed methods can be used to merge DataFrames, depending on the use case.

Scorecard

  • 10–12: Pandas Pro! You’re ready to tackle real-world data.
  • 7–9: Great job! A little more practice, and you’ll be unstoppable.
  • 4–6: Keep learning! Visit The Coding College for more tutorials.
  • 0–3: Don’t worry—start with our beginner-friendly Pandas tutorials!

Learn with The Coding College

At The Coding College, we help coders at all levels master programming and data analysis. Visit The Coding College for:

  • Hands-on Pandas tutorials.
  • Interactive projects for practice.
  • Tips and tricks to excel in coding.

Let’s make data analysis fun and rewarding! 🚀

Leave a Comment