Challenge - 5 Problems
String Case Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of converting pandas Series to lowercase
What is the output of this code snippet?
Pandas
import pandas as pd s = pd.Series(['Apple', 'Banana', 'Cherry']) result = s.str.lower() print(result)
Attempts:
2 left
💡 Hint
Use str.lower() to convert all strings in the Series to lowercase.
✗ Incorrect
The str.lower() method converts each string in the pandas Series to lowercase, preserving the Series structure and index.
❓ data_output
intermediate2:00remaining
Count uppercase strings in a pandas Series
Given the Series below, how many strings are fully uppercase?
Pandas
import pandas as pd s = pd.Series(['dog', 'CAT', 'Bird', 'FISH']) upper_s = s.str.upper() count_upper = sum(upper_s == s)
Attempts:
2 left
💡 Hint
Compare the original Series with the uppercase version to find matches.
✗ Incorrect
Only 'CAT' and 'FISH' are already uppercase, so after str.upper(), they remain the same. The count is 2.
🔧 Debug
advanced2:00remaining
Identify the error in using str.lower() on a DataFrame column
What error does this code raise?
Pandas
import pandas as pd df = pd.DataFrame({'Name': ['Alice', 'Bob', 'CHARLIE']}) df['Name_lower'] = df['Name'].lower()
Attempts:
2 left
💡 Hint
Check if the pandas Series supports the lower() method directly.
✗ Incorrect
The lower() method is a string method, not a pandas Series method. Use str.lower() instead.
🚀 Application
advanced2:00remaining
Filter DataFrame rows with uppercase names
Which code correctly filters rows where the 'Name' column is fully uppercase?
Pandas
import pandas as pd df = pd.DataFrame({'Name': ['ALICE', 'Bob', 'CHARLIE', 'dave']})
Attempts:
2 left
💡 Hint
Use a string method that checks if all characters are uppercase.
✗ Incorrect
str.isupper() returns True for strings that are fully uppercase, so option D filters correctly.
🧠 Conceptual
expert2:00remaining
Understanding behavior of str.upper() with missing values
What is the output of this code?
Pandas
import pandas as pd s = pd.Series(['hello', None, 'WORLD']) result = s.str.upper() print(result)
Attempts:
2 left
💡 Hint
Check how pandas handles None values in string operations.
✗ Incorrect
pandas converts None to NaN in object dtype Series and str.upper() returns NaN for missing values.