Recall & Review
beginner
What does the
str.lower() method do in pandas?It converts all characters in a string column of a pandas DataFrame or Series to lowercase letters.
Click to reveal answer
beginner
How does
str.upper() affect text data in pandas?It changes all characters in a string column to uppercase letters, making the text all capitalized.
Click to reveal answer
beginner
Example: What will
df['Name'].str.lower() do if df['Name'] contains ['Alice', 'BOB', 'Charlie']?It will return a Series with ['alice', 'bob', 'charlie'], converting all names to lowercase.
Click to reveal answer
intermediate
Can
str.lower() and str.upper() be used on non-string columns in pandas?No, these methods only work on string columns. Non-string columns must be converted to strings first.
Click to reveal answer
beginner
Why might you want to use
str.lower() or str.upper() in data cleaning?To standardize text data so that comparisons and searches are case-insensitive and consistent.
Click to reveal answer
What does
df['City'].str.upper() do in pandas?✗ Incorrect
The
str.upper() method converts all characters in the string column to uppercase.If you want to make text comparisons case-insensitive, which method helps?
✗ Incorrect
Using
str.lower() converts all text to lowercase, making comparisons ignore case differences.What happens if you use
str.upper() on a numeric column without converting it first?✗ Incorrect
The
str.upper() method only works on string data; numeric columns must be converted first.Which pandas attribute allows you to apply string methods like
lower() and upper()?✗ Incorrect
The
str accessor is used to apply string methods on pandas Series or DataFrame columns.What is the output of
pd.Series(['Hi', 'Bye']).str.lower()?✗ Incorrect
The
str.lower() method converts all strings in the Series to lowercase.Explain how and why you would use
str.lower() and str.upper() in cleaning text data in pandas.Think about making text uniform to avoid mismatches.
You got /4 concepts.
Describe what happens if you try to use
str.upper() on a numeric column in pandas and how to fix it.Consider data types and method compatibility.
You got /4 concepts.