Help on class StringMethods in module pandas.core.strings.accessor:
class StringMethods(pandas.core.base.NoNewAttributesMixin)
| StringMethods(data)
|
| Vectorized string functions for Series and Index.
|
| NAs stay NA unless handled otherwise by a particular method.
| Patterned after Python's string methods, with some inspiration from
| R's stringr package.
|
| Examples
| --------
| >>> s = pd.Series(["A_Str_Series"])
| >>> s
| 0 A_Str_Series
| dtype: object
|
| >>> s.str.split("_")
| 0 [A, Str, Series]
| dtype: object
|
| >>> s.str.replace("_", "")
| 0 AStrSeries
| dtype: object
|
| Method resolution order:
| StringMethods
| pandas.core.base.NoNewAttributesMixin
| builtins.object
|
| Methods defined here:
|
| __getitem__(self, key)
|
| __init__(self, data)
| Initialize self. See help(type(self)) for accurate signature.
|
| __iter__(self)
|
| capitalize(self)
| Convert strings in the Series/Index to be capitalized.
|
| Equivalent to :meth:`str.capitalize`.
|
| Returns
| -------
| Series or Index of object
|
| See Also
| --------
| 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.
| Series.str.casefold: Removes all case distinctions in the string.
|
| Examples
| --------
| >>> s = pd.Series(['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe'])
| >>> s
| 0 lower
| 1 CAPITALS
| 2 this is a sentence
| 3 SwApCaSe
| dtype: object
|
| >>> 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
|
| casefold(self)
| Convert strings in the Series/Index to be casefolded.
|
| .. versionadded:: 0.25.0
|
| Equivalent to :meth:`str.casefold`.
|
| Returns
| -------
| Series or Index of object
|
| See Also
| --------
| 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.
| Series.str.casefold: Removes all case distinctions in the string.
|
| Examples
| --------
| >>> s = pd.Series(['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe'])
| >>> s
| 0 lower
| 1 CAPITALS
| 2 this is a sentence
| 3 SwApCaSe
| dtype: object
|
| >>> 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
|
| cat(self, others=None, sep=None, na_rep=None, join='left')
| Concatenate strings in the Series/Index with given separator.
|
| If `others` is specified, this function concatenates the Series/Index
| and elements of `others` element-wise.
| If `others` is not passed, then all values in the Series/Index are
| concatenated into a single string with a given `sep`.
|
| Parameters
| ----------
| others : Series, Index, DataFrame, np.ndarray or list-like
| Series, Index, DataFrame, np.ndarray (one- or two-dimensional) and
| other list-likes of strings must have the same length as the
| calling Series/Index, with the exception of indexed objects (i.e.
| Series/Index/DataFrame) if `join` is not None.
|
| If others is a list-like that contains a combination of Series,
| Index or np.ndarray (1-dim), then all elements will be unpacked and
| must satisfy the above criteria individually.
|
| If others is None, the method returns the concatenation of all
| strings in the calling Series/Index.
| sep : str, default ''
| The separator between the different elements/columns. By default
| the empty string `''` is used.
| na_rep : str or None, default None
| Representation that is inserted for all missing values:
|
| - If `na_rep` is None, and `others` is None, missing values in the
| Series/Index are omitted from the result.
| - If `na_rep` is None, and `others` is not None, a row containing a
| missing value in any of the columns (before concatenation) will
| have a missing value in the result.
| join : {'left', 'right', 'outer', 'inner'}, default 'left'
| Determines the join-style between the calling Series/Index and any
| Series/Index/DataFrame in `others` (objects without an index need
| to match the length of the calling Series/Index). To disable
| alignment, use `.values` on any Series/Index/DataFrame in `others`.
|
| .. versionadded:: 0.23.0
| .. versionchanged:: 1.0.0
| Changed default of `join` from None to `'left'`.
|
| Returns
| -------
| str, Series or Index
| If `others` is None, `str` is returned, otherwise a `Series/Index`
| (same type as caller) of objects is returned.
|
| See Also
| --------
| split : Split each string in the Series/Index.
| join : Join lists contained as elements in the Series/Index.
|
| Examples
| --------
| Whe