MCPcopy
hub / github.com/pandas-dev/pandas / title

Method title

pandas/core/strings/accessor.py:3994–4063  ·  view source on GitHub ↗

Convert strings in the Series/Index to titlecase. Equivalent to :meth:`str.title`. Returns ------- Series or Index of objects A Series or Index where the strings are modified by :meth:`str.title`. See Also -------- Serie

(self)

Source from the content-addressed store, hash-verified

3992
3993 @forbid_nonstring_types(["bytes"])
3994 def title(self):
3995 """
3996 Convert strings in the Series/Index to titlecase.
3997
3998 Equivalent to :meth:`str.title`.
3999
4000 Returns
4001 -------
4002 Series or Index of objects
4003 A Series or Index where the strings are modified by :meth:`str.title`.
4004
4005 See Also
4006 --------
4007 Series.str.lower : Converts all characters to lowercase.
4008 Series.str.upper : Converts all characters to uppercase.
4009 Series.str.title : Converts first character of each word to uppercase and
4010 remaining to lowercase.
4011 Series.str.capitalize : Converts first character to uppercase and
4012 remaining to lowercase.
4013 Series.str.swapcase : Converts uppercase to lowercase and lowercase to
4014 uppercase.
4015 Series.str.casefold: Removes all case distinctions in the string.
4016
4017 Examples
4018 --------
4019 >>> s = pd.Series(["lower", "CAPITALS", "this is a sentence", "SwApCaSe"])
4020 >>> s
4021 0 lower
4022 1 CAPITALS
4023 2 this is a sentence
4024 3 SwApCaSe
4025 dtype: str
4026
4027 >>> s.str.lower()
4028 0 lower
4029 1 capitals
4030 2 this is a sentence
4031 3 swapcase
4032 dtype: str
4033
4034 >>> s.str.upper()
4035 0 LOWER
4036 1 CAPITALS
4037 2 THIS IS A SENTENCE
4038 3 SWAPCASE
4039 dtype: str
4040
4041 >>> s.str.title()
4042 0 Lower
4043 1 Capitals
4044 2 This Is A Sentence
4045 3 Swapcase
4046 dtype: str
4047
4048 >>> s.str.capitalize()
4049 0 Lower
4050 1 Capitals
4051 2 This is a sentence

Callers 5

time_titleMethod · 0.80
test_titleFunction · 0.80
test_title_mixed_objectFunction · 0.80
test_casemethodsFunction · 0.80
test_empty_str_methodsFunction · 0.80

Calls 2

_wrap_resultMethod · 0.95
_str_titleMethod · 0.45

Tested by 4

test_titleFunction · 0.64
test_title_mixed_objectFunction · 0.64
test_casemethodsFunction · 0.64
test_empty_str_methodsFunction · 0.64