0
0
Data Analysis Pythondata~5 mins

String methods on Series in Data Analysis Python - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
A.s
B.str
C.text
D.string
What does series.str.upper() do?
ARemoves uppercase letters from strings
BChecks if strings contain uppercase letters
CConverts all strings in the Series to uppercase
DSplits strings at uppercase letters
If a Series has missing values (NaN), what happens when you use series.str.len()?
AReturns NaN for missing values
BRaises an error
CIgnores missing values and returns length for others
DReplaces missing values with zero
How do you check if strings in a Series start with 'data'?
Aseries.str.startswith('data')
Bseries.str.contains('data')
Cseries.str.find('data')
Dseries.str.match('data')
What does series.str.split(',') return?
AA single string with commas removed
BAn error because split is not supported
CA boolean Series if commas exist
DA Series of lists splitting strings at commas
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.