@@ -2151,12 +2151,45 @@ def encode(self, encoding, errors="strict"):
2151
2151
return self ._wrap_result (result )
2152
2152
2153
2153
_shared_docs ['str_strip' ] = ("""
2154
- Strip whitespace (including newlines) from each string in the
2155
- Series/Index from %(side)s. Equivalent to :meth:`str.%(method)s`.
2154
+ Remove leading and trailing characters.
2155
+
2156
+ Strip whitespaces (including newlines) or a set of specified characters
2157
+ from each string in the Series/Index from %(side)s.
2158
+ Equivalent to :meth:`str.%(method)s`.
2159
+
2160
+ Parameters
2161
+ ----------
2162
+ to_strip : str
2163
+ specifying the set of characters to be removed.
2164
+ All combinations of this set of characters will be stripped.
2165
+ Default value is None, which means whaitspaces will be removed.
2156
2166
2157
2167
Returns
2158
2168
-------
2159
2169
stripped : Series/Index of objects
2170
+
2171
+ Examples
2172
+ --------
2173
+ Striping whitespaces for Series
2174
+
2175
+ >>>s = pd.Series([' ant', 'bee ', ' cat '])
2176
+ >>>s
2177
+ 0 ant
2178
+ 1 bee
2179
+ 2 cat
2180
+ dtype: object
2181
+ >>>s.str.strip()
2182
+ 0 ant
2183
+ 1 bee
2184
+ 2 cat
2185
+ dtype: object
2186
+
2187
+ Striping a set of characters for Index
2188
+ >>>df = pd.DataFrame(index=['1.ant ','2._bee__','3. cat_'])
2189
+ >>>pd.index
2190
+ Index(['1.ant ', '2._bee__', '3. cat_'], dtype='object')
2191
+ >>>df.index.str.strip('123._ ')
2192
+ Index(['ant', 'bee', 'cat'], dtype='object')
2160
2193
""" )
2161
2194
2162
2195
@Appender (_shared_docs ['str_strip' ] % dict (side = 'left and right sides' ,
0 commit comments