Skip to content

Commit f5cfee7

Browse files
HamishpkTomAugspurger
authored andcommitted
DOC: Improving the docstring of Series.str.upper and related (#20462)
1 parent b1c54f4 commit f5cfee7

File tree

1 file changed

+58
-1
lines changed

1 file changed

+58
-1
lines changed

pandas/core/strings.py

+58-1
Original file line numberDiff line numberDiff line change
@@ -2257,11 +2257,68 @@ def rindex(self, sub, start=0, end=None):
22572257

22582258
_shared_docs['casemethods'] = ("""
22592259
Convert strings in the Series/Index to %(type)s.
2260+
22602261
Equivalent to :meth:`str.%(method)s`.
22612262
22622263
Returns
22632264
-------
2264-
converted : Series/Index of objects
2265+
Series/Index of objects
2266+
2267+
See Also
2268+
--------
2269+
Series.str.lower : Converts all characters to lowercase.
2270+
Series.str.upper : Converts all characters to uppercase.
2271+
Series.str.title : Converts first character of each word to uppercase and
2272+
remaining to lowercase.
2273+
Series.str.capitalize : Converts first character to uppercase and
2274+
remaining to lowercase.
2275+
Series.str.swapcase : Converts uppercase to lowercase and lowercase to
2276+
uppercase.
2277+
2278+
Examples
2279+
--------
2280+
>>> s = pd.Series(['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe'])
2281+
>>> s
2282+
0 lower
2283+
1 CAPITALS
2284+
2 this is a sentence
2285+
3 SwApCaSe
2286+
dtype: object
2287+
2288+
>>> s.str.lower()
2289+
0 lower
2290+
1 capitals
2291+
2 this is a sentence
2292+
3 swapcase
2293+
dtype: object
2294+
2295+
>>> s.str.upper()
2296+
0 LOWER
2297+
1 CAPITALS
2298+
2 THIS IS A SENTENCE
2299+
3 SWAPCASE
2300+
dtype: object
2301+
2302+
>>> s.str.title()
2303+
0 Lower
2304+
1 Capitals
2305+
2 This Is A Sentence
2306+
3 Swapcase
2307+
dtype: object
2308+
2309+
>>> s.str.capitalize()
2310+
0 Lower
2311+
1 Capitals
2312+
2 This is a sentence
2313+
3 Swapcase
2314+
dtype: object
2315+
2316+
>>> s.str.swapcase()
2317+
0 LOWER
2318+
1 capitals
2319+
2 THIS IS A SENTENCE
2320+
3 sWaPcAsE
2321+
dtype: object
22652322
""")
22662323
_shared_docs['lower'] = dict(type='lowercase', method='lower')
22672324
_shared_docs['upper'] = dict(type='uppercase', method='upper')

0 commit comments

Comments
 (0)