Python Pandas Quiz

Last Updated :
Discuss
Comments

Question 1

Question: What is the purpose of the pivot_table() function in Pandas?

  • To create a new DataFrame

  • To pivot rows and columns in a DataFrame

  • To perform statistical operations on a DataFrame

  • To create a summary table

Question 2

How can you handle missing values in a Pandas DataFrame?

  • Use df.fillna(value) to replace missing values

  • Use df.dropna() to remove rows with missing values

  • Both A and B

  • Neither A nor B

Question 3

Question: How can you handle duplicate values in a Pandas DataFrame?

  • Use the df.drop_duplicates() method

  • Use the df.remove_duplicates() method

  • Use the df.drop_duplicate_rows() method

  • Use the df.eliminate_duplicates() method

Question 4

What is the purpose of the melt() function in Pandas?

  • To melt a DataFrame into a longer format

  • To create a melted cheese plot

  • To melt a DataFrame into a wider format

  • To melt a DataFrame into a binary format

Question 5

What does the nunique() method in Pandas calculate?

  • The number of non-null values

  • The number of unique values

  • The number of distinct groups

  • The number of unique rows

Question 6

How can you perform a time-based resampling in Pandas?

  • df.resample()

  • df.time_resample()

  • df.groupby("time_column").resample()

  • df.time_groupby().resample()

Question 7

How can you save a Pandas DataFrame to a CSV file?

  • df.save_csv("filename.csv")

  • df.write_csv("filename.csv")

  • df.to_csv("filename.csv")

  • df.export_csv("filename.csv")

Question 8

Question: What does the nlargest() method in Pandas do?

  • Returns the smallest values in a DataFrame

  • Returns the largest values in a DataFrame

  • Returns the smallest values in a column

  • Returns the largest values in a column

Question 9

How can you reset the index of a Pandas DataFrame?

  • df.reset_index()

  • df.set_index()

  • df.index_reset()

  • df.index_reset()

Question 10

What is the purpose of the pd.cut() function in Pandas?

  • To cut a DataFrame into smaller pieces

  • To categorize continuous data into discrete bins

  • To remove duplicate values from a DataFrame

  • To concatenate DataFrames along a particular axis

There are 25 questions to complete.

Take a part in the ongoing discussion