Python Pandas Quiz

Last Updated :
Discuss
Comments

Question 1

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

  • A

    To create a new DataFrame

  • B

    To pivot rows and columns in a DataFrame

  • C

    To perform statistical operations on a DataFrame

  • D

    To create a summary table

Question 2

How can you handle missing values in a Pandas DataFrame?

  • A

    Use df.fillna(value) to replace missing values

  • B

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

  • C

    Both A and B

  • D

    Neither A nor B

Question 3

How can you handle duplicate values in a Pandas DataFrame?

  • A

    Use the df.drop_duplicates() method

  • B

    Use the df.remove_duplicates() method

  • C

    Use the df.drop_duplicate_rows() method

  • D

    Use the df.eliminate_duplicates() method

Question 4

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

  • A

    To melt a DataFrame into a longer format

  • B

    To create a melted cheese plot

  • C

    To melt a DataFrame into a wider format

  • D

    To melt a DataFrame into a binary format

Question 5

What does the nunique() method in Pandas calculate?

  • A

    The number of non-null values

  • B

    The number of unique values

  • C

    The number of distinct groups

  • D

    The number of unique rows

Question 6

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

  • A

    df.resample()

  • B

    df.time_resample()

  • C

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

  • D

    df.time_groupby().resample()

Question 7

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

  • A

    df.save_csv("filename.csv")

  • B

    df.write_csv("filename.csv")

  • C

    df.to_csv("filename.csv")

  • D

    df.export_csv("filename.csv")

Question 8

What does the nlargest() method in Pandas do?

  • A

    Returns the smallest values in a DataFrame

  • B

    Returns the largest values in a DataFrame

  • C

    Returns the smallest values in a column

  • D

    Returns the largest values in a column

Question 9

How can you reset the index of a Pandas DataFrame?

  • A

    df.reset_index()

  • B

    df.set_index()

  • C

    df.index_reset()

  • D

    df.index_reset()

Question 10

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

  • A

    To cut a DataFrame into smaller pieces

  • B

    To categorize continuous data into discrete bins

  • C

    To remove duplicate values from a DataFrame

  • D

    To concatenate DataFrames along a particular axis

There are 25 questions to complete.

Take a part in the ongoing discussion