0
0
Data Analysis Pythondata~20 mins

First data analysis walkthrough in Data Analysis Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
First 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 filtering
What is the output of this code that filters rows where age is greater than 30?
Data Analysis Python
import pandas as pd

data = {'name': ['Alice', 'Bob', 'Charlie', 'David'], 'age': [25, 35, 30, 40]}
df = pd.DataFrame(data)
filtered = df[df['age'] > 30]
print(filtered)
A
    name  age
1    Bob   35
3  David   40
B
Empty DataFrame
Columns: [name, age]
Index: []
C
    name  age
1    Bob   35
2  Charlie 30
3  David  40
D
    name  age
0  Alice   25
2  Charlie 30
Attempts:
2 left
💡 Hint
Look for rows where the age value is strictly greater than 30.
data_output
intermediate
1:30remaining
Count unique values in a column
What is the output of this code that counts unique values in the 'city' column?
Data Analysis Python
import pandas as pd

data = {'name': ['Anna', 'Ben', 'Cara', 'Dan'], 'city': ['NY', 'LA', 'NY', 'SF']}
df = pd.DataFrame(data)
count = df['city'].nunique()
print(count)
A4
B3
C2
DError: AttributeError
Attempts:
2 left
💡 Hint
Count how many different cities appear in the list.
visualization
advanced
2:30remaining
Identify the correct bar chart output
Which option shows the correct bar chart output for the count of fruits in this data?
Data Analysis Python
import pandas as pd
import matplotlib.pyplot as plt

data = {'fruit': ['apple', 'banana', 'apple', 'orange', 'banana', 'banana']}
df = pd.DataFrame(data)
counts = df['fruit'].value_counts()
counts.plot(kind='bar')
plt.show()
ABar chart with bars: banana=3, apple=2, orange=1
BBar chart with bars: apple=3, banana=2, orange=1
CBar chart with bars: orange=3, apple=2, banana=1
DBar chart with bars: apple=1, banana=1, orange=1
Attempts:
2 left
💡 Hint
Count how many times each fruit appears in the list.
🔧 Debug
advanced
2:00remaining
Identify the error in data aggregation code
What error does this code produce when trying to calculate the mean age grouped by city?
Data Analysis Python
import pandas as pd

data = {'name': ['Eve', 'Frank'], 'age': [28, 33], 'city': ['NY', 'LA']}
df = pd.DataFrame(data)
result = df.groupby('city')['age'].mean
print(result())
AAttributeError: 'DataFrame' object has no attribute 'groupby'
BKeyError: 'age'
CTypeError: 'method' object is not callable
DNo error, prints mean ages
Attempts:
2 left
💡 Hint
Check if the mean function is called correctly.
🚀 Application
expert
2:30remaining
Determine the number of rows after multiple filters
Given this DataFrame, how many rows remain after filtering for age >= 30 and city == 'NY'?
Data Analysis Python
import pandas as pd

data = {'name': ['Gina', 'Hank', 'Ivy', 'Jack'], 'age': [29, 31, 30, 35], 'city': ['NY', 'NY', 'LA', 'NY']}
df = pd.DataFrame(data)
filtered = df[(df['age'] >= 30) & (df['city'] == 'NY')]
print(len(filtered))
A0
B3
C1
D2
Attempts:
2 left
💡 Hint
Check each row if both conditions are true.