Bird
Raised Fist0
Pandasdata~20 mins

Exploratory data analysis workflow in Pandas - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Exploratory Data Analysis Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
Output of basic data summary
What is the output of the following code snippet that summarizes a DataFrame?
Pandas
import pandas as pd

data = {'Age': [25, 30, 22, 40, 28], 'Salary': [50000, 60000, 45000, 80000, 52000]}
df = pd.DataFrame(data)
summary = df.describe()
print(summary)
A{'Age': {'count': 5.0, 'mean': 29.0, 'std': 7.071, 'min': 22.0, '25%': 25.0, '50%': 28.0, '75%': 30.0, 'max': 40.0}, 'Salary': {'count': 5.0, 'mean': 57400.0, 'std': 13435.028, 'min': 45000.0, '25%': 50000.0, '50%': 52000.0, '75%': 60000.0, 'max': 80000.0}}
B
   Age  Salary
0   25   50000
1   30   60000
2   22   45000
3   40   80000
4   28   52000
C
       Age        Salary
count   5.0      5.000000
mean   29.0  57400.000000
std     7.071 13435.028
min    22.0  45000.000000
25%    25.0  50000.000000
50%    28.0  52000.000000
75%    30.0  60000.000000
max    40.0  80000.000000
D
Age       29.0
Salary  57400.0
dtype: float64
Attempts:
2 left
💡 Hint
Look at the output of pandas DataFrame describe() method.
❓ data_output
intermediate
2:00remaining
Count of missing values per column
Given the DataFrame below, what is the output of counting missing values per column?
Pandas
import pandas as pd
import numpy as np

data = {'Name': ['Alice', 'Bob', None, 'David'], 'Age': [25, None, 22, 40], 'Salary': [50000, 60000, 45000, None]}
df = pd.DataFrame(data)
missing_counts = df.isnull().sum()
print(missing_counts)
A
Name      1
Age       1
Salary    1
dtype: int64
B
Name      1
Age       0
Salary    1
dtype: int64
C
Name      0
Age       1
Salary    1
dtype: int64
D
Name      1
Age       1
Salary    0
dtype: int64
Attempts:
2 left
💡 Hint
Check which values are None or np.nan in each column.
❓ visualization
advanced
2:00remaining
Correct histogram plot code
Which option produces a histogram plot of the 'Age' column with 5 bins using matplotlib?
Pandas
import pandas as pd
import matplotlib.pyplot as plt

data = {'Age': [25, 30, 22, 40, 28, 35, 33, 31, 29, 27]}
df = pd.DataFrame(data)

# Choose the correct code to plot histogram
A
df.plot.hist('Age', bins=5)
plt.show()
B
df['Age'].plot.hist(bins=5)
plt.show()
C
plt.plot(df['Age'], bins=5)
plt.show()
D
plt.hist(df['Age'], bins=5)
plt.show()
Attempts:
2 left
💡 Hint
matplotlib's hist function takes data and bins as arguments.
🔧 Debug
advanced
2:00remaining
Identify error in groupby aggregation
What error does the following code raise?
Pandas
import pandas as pd

data = {'Category': ['A', 'B', 'A', 'B'], 'Value': [10, 20, 15, 25]}
df = pd.DataFrame(data)
result = df.groupby('Category').agg({'Value': 'sum', 'NonExistent': 'mean'})
print(result)
AKeyError: 'NonExistent'
BTypeError: unsupported operand type(s) for +: 'int' and 'str'
CValueError: No numeric types to aggregate
DNo error, prints grouped sums and means
Attempts:
2 left
💡 Hint
Check if all keys in agg dictionary exist in DataFrame columns.
🚀 Application
expert
3:00remaining
Calculate correlation matrix and interpret output
Given the DataFrame below, what is the correlation coefficient between 'X' and 'Y'?
Pandas
import pandas as pd
import numpy as np

data = {'X': [1, 2, 3, 4, 5], 'Y': [2, 4, 6, 8, 10], 'Z': [5, 4, 3, 2, 1]}
df = pd.DataFrame(data)
corr_matrix = df.corr()
print(round(corr_matrix.loc['X', 'Y'], 2))
A-1.00
B1.00
C0.00
D0.50
Attempts:
2 left
💡 Hint
Check if Y is a perfect linear function of X.

Practice

(1/5)
1. Which step is usually done first in an exploratory data analysis workflow?
easy
A. Viewing the first few rows of the dataset
B. Creating complex machine learning models
C. Removing all missing values immediately
D. Generating final reports without checking data

Solution

  1. Step 1: Understand the initial data

    Exploratory data analysis starts by looking at the first few rows to get a feel for the data structure and values.
  2. Step 2: Avoid premature actions

    Jumping to modeling or removing missing data without understanding can cause mistakes.
  3. Final Answer:

    Viewing the first few rows of the dataset -> Option A
  4. Quick Check:

    First step = View data sample [OK]
Hint: Always start by looking at data samples [OK]
Common Mistakes:
  • Starting with modeling before understanding data
  • Removing missing values without checking their impact
  • Ignoring data overview and jumping to conclusions
2. Which pandas command correctly shows summary statistics of numeric columns in a DataFrame df?
easy
A. df.head()
B. df.info()
C. df.describe()
D. df.sample()

Solution

  1. Step 1: Identify summary statistics function

    df.describe() returns count, mean, std, min, max, and quartiles for numeric columns.
  2. Step 2: Differentiate other commands

    df.head() shows first rows, df.info() shows data types, and df.sample() shows random rows.
  3. Final Answer:

    df.describe() -> Option C
  4. Quick Check:

    Summary stats = df.describe() [OK]
Hint: Use df.describe() for quick numeric summaries [OK]
Common Mistakes:
  • Using df.head() to get statistics
  • Confusing df.info() with statistical summary
  • Expecting df.sample() to summarize data
3. Given the DataFrame df below, what is the output of df.isnull().sum()?
import pandas as pd
data = {'A': [1, 2, None], 'B': [None, 2, 3], 'C': [1, 2, 3]}
df = pd.DataFrame(data)
medium
A. {'A': 1, 'B': 1, 'C': 0}
B. {'A': 0, 'B': 0, 'C': 0}
C. {'A': 1, 'B': 2, 'C': 1}
D. {'A': 2, 'B': 1, 'C': 0}

Solution

  1. Step 1: Check missing values per column

    Column 'A' has one None, 'B' has one None, 'C' has none.
  2. Step 2: Use isnull().sum() to count missing

    This method counts missing values per column, so output is {'A': 1, 'B': 1, 'C': 0}.
  3. Final Answer:

    {'A': 1, 'B': 1, 'C': 0} -> Option A
  4. Quick Check:

    Missing counts = {'A':1,'B':1,'C':0} [OK]
Hint: Count missing with df.isnull().sum() [OK]
Common Mistakes:
  • Counting total missing instead of per column
  • Confusing None with zero or empty string
  • Misreading which columns have missing values
4. You run df.info() but get an error: AttributeError: 'DataFrame' object has no attribute 'infoo'. What is the likely cause?
medium
A. The DataFrame is empty
B. You typed the method name incorrectly
C. The pandas library is not imported
D. The DataFrame has no columns

Solution

  1. Step 1: Check the error message

    The error says 'infoo' attribute not found, which suggests a typo in method name.
  2. Step 2: Confirm correct method name

    The correct method is df.info() with one 'o'.
  3. Final Answer:

    You typed the method name incorrectly -> Option B
  4. Quick Check:

    Typo in method name = error [OK]
Hint: Check spelling of method names carefully [OK]
Common Mistakes:
  • Assuming empty DataFrame causes this error
  • Forgetting to import pandas
  • Thinking DataFrame must have columns to use info()
5. You have a DataFrame df with columns ['Age', 'Salary', 'Department']. You want to find the average salary per department but only for employees older than 30. Which pandas workflow is correct?
hard
A. df.groupby('Department')['Salary'].mean()
B. df['Salary'].mean().groupby('Department')[df['Age'] > 30]
C. df.groupby('Department').mean()['Salary'][df['Age'] > 30]
D. df[df['Age'] > 30].groupby('Department')['Salary'].mean()

Solution

  1. Step 1: Filter rows where Age > 30

    Use df[df['Age'] > 30] to keep only employees older than 30.
  2. Step 2: Group filtered data by Department and calculate mean Salary

    Apply .groupby('Department')['Salary'].mean() on filtered data to get average salary per department.
  3. Final Answer:

    df[df['Age'] > 30].groupby('Department')['Salary'].mean() -> Option D
  4. Quick Check:

    Filter then group and mean = df[df['Age'] > 30].groupby('Department')['Salary'].mean() [OK]
Hint: Filter first, then group and aggregate [OK]
Common Mistakes:
  • Grouping before filtering data
  • Trying to filter after aggregation
  • Using mean() without grouping
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard