Recall & Review
beginner
What does the
str.split() method do in pandas?It splits each string in a pandas Series or DataFrame column into parts based on a separator, returning a list or expanding into multiple columns.
Click to reveal answer
beginner
How do you split a pandas Series column into multiple columns using
str.split()?Use
str.split(pat, expand=True). The expand=True makes the split parts become separate columns.Click to reveal answer
beginner
What is the default separator for
str.split() in pandas?The default separator is any whitespace (spaces, tabs, newlines).
Click to reveal answer
intermediate
How can you limit the number of splits when using
str.split()?Use the
n parameter to specify the maximum number of splits to do from the left.Click to reveal answer
beginner
What happens if you use
str.split() without expand=True?The result is a Series of lists, where each list contains the split parts of the original string.
Click to reveal answer
What does
expand=True do in str.split()?✗ Incorrect
expand=True makes the split parts become separate columns in the DataFrame.
What is the default separator used by
str.split() in pandas?✗ Incorrect
The default separator is any whitespace like spaces or tabs.
If you want to split a string only once from the left, which parameter do you use?
✗ Incorrect
The n parameter limits the number of splits from the left.
What type of object does
str.split() return by default?✗ Incorrect
By default, it returns a Series where each element is a list of split parts.
Which of these is a correct way to split a pandas Series column named 'Name' by comma and expand into columns?
✗ Incorrect
The correct syntax is df['Name'].str.split(',', expand=True).
Explain how to split a pandas Series column into multiple columns using
str.split().Think about how to turn one column with strings into several columns.
You got /3 concepts.
Describe the difference in output when using
str.split() with and without expand=True.Consider the shape and type of the output.
You got /3 concepts.