@@ -2159,46 +2159,52 @@ def encode(self, encoding, errors="strict"):
2159
2159
2160
2160
Parameters
2161
2161
----------
2162
- to_strip : str, optional
2162
+ to_strip : str or None, default None (whitespaces are removed)
2163
2163
Specifying the set of characters to be removed.
2164
2164
All combinations of this set of characters will be stripped.
2165
- Default value is None, which means whaitspaces will be removed.
2166
2165
2167
2166
Returns
2168
2167
-------
2169
- stripped : Series/Index of objects
2168
+ Series/Index of objects
2170
2169
2171
2170
See Also
2172
2171
--------
2173
- str.slice : Slice substrings from each element in the Series/Index
2172
+ Series.str.strip : Remove leading and trailing characters in Series/Index
2173
+ Series.str.lstrip : Remove leading characters in Series/Index
2174
+ Series.str.rstrip : Remove trailing characters in Series/Index
2174
2175
2175
2176
Examples
2176
2177
--------
2177
- Stripping whitespaces for Series
2178
-
2179
- >>> s = pd.Series([' ant', 'bee ', ' cat '])
2180
-
2178
+ >>> s = pd.Series(['1. Ant. ', '2. Bee!\n ', '3. Cat?\t '])
2181
2179
>>> s
2182
- 0 ant
2183
- 1 bee
2184
- 2 cat
2180
+ 0 1. Ant.
2181
+ 1 2. Bee! \n
2182
+ 2 3. Cat? \t
2185
2183
dtype: object
2186
2184
2187
2185
>>> s.str.strip()
2188
- 0 ant
2189
- 1 bee
2190
- 2 cat
2186
+ 0 1. Ant.
2187
+ 1 2. Bee!
2188
+ 2 3. Cat?
2191
2189
dtype: object
2192
2190
2193
- Stripping a set of characters for Index
2194
-
2195
- >>> idx = pd.Index(['1.ant ','2._bee__','3. cat_'])
2191
+ >>> s.str.strip('123.!? \n \t ')
2192
+ 0 Ant
2193
+ 1 Bee
2194
+ 2 Cat
2195
+ dtype: object
2196
2196
2197
- >>> idx
2198
- Index(['1.ant ', '2._bee__', '3. cat_'], dtype='object')
2197
+ >>> s.str.lstrip('123.!? \n \t ')
2198
+ 0 Ant.
2199
+ 1 Bee!\n
2200
+ 2 Cat?\t
2201
+ dtype: object
2199
2202
2200
- >>> idx.str.strip('123._ ')
2201
- Index(['ant', 'bee', 'cat'], dtype='object')
2203
+ >>> s.str.rstrip('123.!? \n \t ')
2204
+ 0 1. Ant
2205
+ 1 2. Bee
2206
+ 2 3. Cat
2207
+ dtype: object
2202
2208
""" )
2203
2209
2204
2210
@Appender (_shared_docs ['str_strip' ] % dict (side = 'left and right sides' ,
0 commit comments