cudf.core.column.string.StringMethods.strip#
- StringMethods.strip(to_strip: str | None = None) SeriesOrIndex[source]#
移除前导和尾随字符。
从Series/Index中的每个字符串的左右两侧去除空白字符(包括换行符)或一组指定的字符。等同于str.strip()。
- Parameters:
- to_stripstr or None, default None
指定要删除的字符集。 这个字符集的所有组合 都将被删除。如果为None,则删除空格。
- Returns:
- Series/Index of str dtype
返回 Series 或 Index。
示例
>>> import cudf >>> s = cudf.Series(['1. Ant. ', '2. Bee!\n', '3. Cat?\t', None]) >>> s 0 1. Ant. 1 2. Bee!\n 2 3. Cat?\t 3 <NA> dtype: object >>> s.str.strip() 0 1. Ant. 1 2. Bee! 2 3. Cat? 3 <NA> dtype: object >>> s.str.strip('123.!? \n\t') 0 Ant 1 Bee 2 Cat 3 <NA> dtype: object