bigframes.pandas.api.typing.StringMethods.strip#

StringMethods.strip(to_strip: str | None = None) T[source]#

Remove leading and trailing characters.

Strip whitespaces (including newlines) or a set of specified characters from each string in the Series/Index from left and right sides. Replaces any non-strings in Series with NaNs. Equivalent to str.strip().

Examples:

>>> import bigframes.pandas as bpd
>>> s = bpd.Series([
...     '1. Ant.',
...     '  2. Bee? ',
...     '\t3. Cat!\n',
...     pd.NA,
... ])
>>> s.str.strip()
0    1. Ant.
1    2. Bee?
2    3. Cat!
3       <NA>
dtype: string
>>> s.str.strip('123.!? \n\t')
0       Ant
1       Bee
2       Cat
3       <NA>
dtype: string
Parameters:

to_strip (str, default None) – Specifying the set of characters to be removed. All combinations of this set of characters will be stripped. If None then whitespaces are removed.

Returns:

Series or Index without leading

and trailing characters.

Return type:

bigframes.series.Series