From 413d4d6daa451c628e33f71b3756461954d1854f Mon Sep 17 00:00:00 2001 From: Hamish Pitkeathly Date: Thu, 22 Mar 2018 21:14:36 +0000 Subject: [PATCH 1/4] DOC: Improving the docstring of Series.str.upper and related --- pandas/core/strings.py | 52 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/pandas/core/strings.py b/pandas/core/strings.py index b98fa106336fc..e8f320a907a07 100644 --- a/pandas/core/strings.py +++ b/pandas/core/strings.py @@ -2145,11 +2145,61 @@ def rindex(self, sub, start=0, end=None): _shared_docs['casemethods'] = (""" Convert strings in the Series/Index to %(type)s. + Equivalent to :meth:`str.%(method)s`. Returns ------- - converted : Series/Index of objects + Series/Index of objects + + See Also + -------- + Series.str.lower : Converts all characters to lower case. + Series.str.upper : Converts all characters to upper case. + Series.str.title : Converts first character of each word to upper case and + remaining to lower case. + Series.str.capitalize : Converts first character to upper case and + remaining to lower case. + Series.str.swapcase : Converts upper case to lower case and lower case to + upper case. + + Examples + -------- + >>> s = pd.Series(['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe']) + >>> s.str.lower() + 0 lower + 1 capitals + 2 this is a sentence + 3 swapcase + dtype: object + + >>> s.str.upper() + 0 LOWER + 1 CAPITALS + 2 THIS IS A SENTENCE + 3 SWAPCASE + dtype: object + + >>> s.str.title() + 0 Lower + 1 Capitals + 2 This Is A Sentence + 3 Swapcase + dtype: object + + >>> s.str.capitalize() + 0 Lower + 1 Capitals + 2 This is a sentence + 3 Swapcase + dtype: object + + >>> s.str.swapcase() + 0 LOWER + 1 capitals + 2 THIS IS A SENTENCE + 3 sWaPcAsE + dtype: object """) _shared_docs['lower'] = dict(type='lowercase', method='lower') _shared_docs['upper'] = dict(type='uppercase', method='upper') From 12bb36728902b44d2a817ba62f094f2dafcafdbf Mon Sep 17 00:00:00 2001 From: Hamish Pitkeathly Date: Sat, 24 Mar 2018 12:33:10 +0000 Subject: [PATCH 2/4] CHanged lower case to lowercase and added s --- pandas/core/strings.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/pandas/core/strings.py b/pandas/core/strings.py index e8f320a907a07..2b573e17fca21 100644 --- a/pandas/core/strings.py +++ b/pandas/core/strings.py @@ -2154,18 +2154,25 @@ def rindex(self, sub, start=0, end=None): See Also -------- - Series.str.lower : Converts all characters to lower case. - Series.str.upper : Converts all characters to upper case. - Series.str.title : Converts first character of each word to upper case and - remaining to lower case. - Series.str.capitalize : Converts first character to upper case and - remaining to lower case. - Series.str.swapcase : Converts upper case to lower case and lower case to - upper case. + Series.str.lower : Converts all characters to lowercase. + Series.str.upper : Converts all characters to uppercase. + Series.str.title : Converts first character of each word to uppercase and + remaining to lowercase. + Series.str.capitalize : Converts first character to uppercase and + remaining to lowercase. + Series.str.swapcase : Converts uppercase to lowercase and lowercase to + uppercase. Examples -------- >>> s = pd.Series(['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe']) + >>> s + 0 lower + 1 CAPITALS + 2 this is a SentEnce + 3 The is Paris + dtype: object + >>> s.str.lower() 0 lower 1 capitals From 82ec922f88e7d1873f07292da5ad691d5a8fedce Mon Sep 17 00:00:00 2001 From: Hamish Pitkeathly Date: Sat, 24 Mar 2018 12:56:44 +0000 Subject: [PATCH 3/4] removed space from line 2175 --- pandas/core/strings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/strings.py b/pandas/core/strings.py index 2b573e17fca21..ea2e7e9049ba5 100644 --- a/pandas/core/strings.py +++ b/pandas/core/strings.py @@ -2172,7 +2172,7 @@ def rindex(self, sub, start=0, end=None): 2 this is a SentEnce 3 The is Paris dtype: object - + >>> s.str.lower() 0 lower 1 capitals From 5dcb7d13d3df73ab7b74342158b3730f80aeaf46 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Wed, 28 Mar 2018 11:21:11 -0500 Subject: [PATCH 4/4] Fixed doctest [ci skip] [ci skip] --- pandas/core/strings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/strings.py b/pandas/core/strings.py index ea2e7e9049ba5..09eed94b36c6b 100644 --- a/pandas/core/strings.py +++ b/pandas/core/strings.py @@ -2169,8 +2169,8 @@ def rindex(self, sub, start=0, end=None): >>> s 0 lower 1 CAPITALS - 2 this is a SentEnce - 3 The is Paris + 2 this is a sentence + 3 SwApCaSe dtype: object >>> s.str.lower()