Recall & Review
beginner
What is a Series in pandas?
A Series is a one-dimensional labeled array in pandas that can hold any data type, like numbers or strings. Think of it like a list with labels for each item.
Click to reveal answer
beginner
How do you access string methods on a pandas Series?
You use the
.str accessor before the string method. For example, series.str.lower() converts all strings in the Series to lowercase.Click to reveal answer
beginner
What does
series.str.contains('abc') do?It checks each string in the Series to see if it contains the substring 'abc'. It returns a Series of True or False values.
Click to reveal answer
intermediate
How can you handle missing values when using string methods on a Series?
Most string methods on Series automatically skip missing values (NaN). You can also use
na='' or na=False in some methods to control behavior.Click to reveal answer
beginner
Give an example of using
series.str.replace().If you have a Series with strings and want to replace 'cat' with 'dog', you can use
series.str.replace('cat', 'dog'). This changes all 'cat' words to 'dog' in the Series.Click to reveal answer
Which pandas accessor allows you to use string methods on a Series?
✗ Incorrect
The correct accessor for string methods on a Series is
.str.What does
series.str.upper() do?✗ Incorrect
series.str.upper() converts all strings in the Series to uppercase.If a Series has missing values (NaN), what happens when you use
series.str.len()?✗ Incorrect
String methods return NaN for missing values by default.
How do you check if strings in a Series start with 'data'?
✗ Incorrect
series.str.startswith('data') checks if strings start with 'data'.What does
series.str.split(',') return?✗ Incorrect
series.str.split(',') splits each string at commas and returns a Series of lists.Explain how to use string methods on a pandas Series and give two examples.
Think about how you call string functions on each item in the Series.
You got /3 concepts.
Describe how missing values are handled when applying string methods on a Series.
Consider what happens if a string method meets a NaN value.
You got /3 concepts.