pandas.Series.str.strip
pandas 3.1.1 · Series and accessors · method
Remove leading and trailing whitespace or the specified set of characters.
Call syntax
Series.str.strip(to_strip=None)Run the example
Edit the example and select Run Python to see the result.
Parameters
| Parameter | Requirement | Accepted values and behavior |
|---|---|---|
to_strip |
Optional Positional or keyword Default None |
str or None Pass the characters to trim from both ends. When omitted, leading and trailing whitespace is removed. |
Returns
Returns the text values with their ends trimmed, preserving the caller’s Series or Index structure.