Analyzing DataFrames

This quiz is designed to test your knowledge of analyzing DataFrames in Python using the Pandas library.

Last Updated :
Discuss
Comments

Question 1

What will df.describe() return?

Python
import pandas as pd
data = {'Name': ['Alice', 'Bob', 'Charlie', 'David'],
        'Age': [24, 27, 22, 32],
        'Score': [85, 90, 88, 78]}
df = pd.DataFrame(data)


  • Summary statistics of all columns, including non-numeric ones

  • Summary statistics of numeric columns only

  • Error, because df.describe() requires numeric-only columns

  • None of the above

Question 2

What is the output of df['Age'].mean()?

  • 24

  • 25.25

  • 27.0

  • 32

Question 3

Which of the following methods is used to check for missing values in a DataFrame?

  • df.has_nan()

  • df.isnull()

  • df.fillna()

  • df.check_nan()

Question 4

Given df, which command will filter rows where the Score is greater than 85?

  • df.filter(df['Score'] > 85)

  • df[df.Score > 85]

  • df.loc[df['Score'] > 85]

  • Both b and c

Question 5

What does the following code do?

Python
df['Category'] = ['A', 'B', 'A', 'B']
df.groupby('Category')['Score'].mean()


  • Computes the mean Score grouped by the Category column

  • Adds a new column with grouped means

  • Creates a DataFrame with grouped means but does not modify df

  • Both a and c

Question 6

How can you reset the index of a DataFrame?

  • df.reset_index()

  • df.set_index(None)

  • df.index_reset()

  • df.reindex()

Question 7

What will the following code output?

Python
df[df['Name'] == 'Alice']


  • A DataFrame with all rows where Name is 'Alice'

  • A Series with the row where Name is 'Alice'

  • An error, because Name is not a numeric column

  • None of the above

Question 8

What does df['Score'] > 80 return?


  • A filtered DataFrame

  • A Boolean Series

  • A DataFrame with True or False values

  • None of the above

Question 9

How do you sort df by the Age column in descending order?

  • df.sort_values(by='Age', ascending=False)

  • df.sort(by='Age', desc=True)

  • df.sort(by='Age', ascending=False)

  • None of the above

Question 10

What does df.info() provide?

  • Descriptive statistics for all columns

  • Data types, non-null counts, and memory usage of columns

  • DataFrame metadata, including shape and size

  • None of the above

Tags:

There are 10 questions to complete.

Take a part in the ongoing discussion