pandas.Series.str.findall   Series.str.findall(pat, flags=0)[source]

Find all occurrences of pattern or regular expression in the Series/Index. Equivalent to applying re.findall() to all the elements in the Series/Index.  Parameters

pat:str

Pattern or regular expression.
flags:int, default 0

Flags from re module, e.g. re.IGNORECASE (default is 0, which means no flags).    Returns
 Series/Index of lists of strings

All non-overlapping matches of pattern or regular expression in each string of this Series/Index.      See also  count

Count occurrences of pattern or regular expression in each string of the Series/Index.  extractall

For each string in the Series, extract groups from all matches of regular expression and return a DataFrame with one row for each match and one column for each group.  re.findall

The equivalent re function to all non-overlapping matches of pattern or regular expression in string, as a list of strings.    Examples
>>> s = pd.Series(['Lion', 'Monkey', 'Rabbit'])
  The search for the pattern ‘Monkey’ returns one match:
>>> s.str.findall('Monkey')
0          []
1    [Monkey]
2          []
dtype: object
  On the other hand, the search for the pattern ‘MONKEY’ doesn’t return any match:
>>> s.str.findall('MONKEY')
0    []
1    []
2    []
dtype: object
  Flags can be added to the pattern or regular expression. For instance, to find the pattern ‘MONKEY’ ignoring the case:
>>> import re
>>> s.str.findall('MONKEY', flags=re.IGNORECASE)
0          []
1    [Monkey]
2          []
dtype: object
  When the pattern matches more than one string in the Series, all matches are returned:
>>> s.str.findall('on')
0    [on]
1    [on]
2      []
dtype: object
  Regular expressions are supported too. For instance, the search for all the strings ending with the word ‘on’ is shown next:
>>> s.str.findall('on$')
0    [on]
1      []
2      []
dtype: object
  If the pattern is found more than once in the same string, then a list of multiple strings is returned:
>>> s.str.findall('b')
0        []
1        []
2    [b, b]
dtype: object


pandas.Series.str.fullmatch   Series.str.fullmatch(pat, case=True, flags=0, na=None)[source]

Determine if each string entirely matches a regular expression.  New in version 1.1.0.   Parameters

pat:str

Character sequence or regular expression.
case:bool, default True

If True, case sensitive.
flags:int, default 0 (no flags)

Regex module flags, e.g. re.IGNORECASE.
na:scalar, optional

Fill value for missing values. The default depends on dtype of the array. For object-dtype, numpy.nan is used. For StringDtype, pandas.NA is used.    Returns
 Series/Index/array of boolean values
    See also  match

Similar, but also returns True when only a prefix of the string matches the regular expression.  extract

Extract matched groups.


pandas.Series.str.get   Series.str.get(i)[source]

Extract element from each component at specified position. Extract element from lists, tuples, or strings in each element in the Series/Index.  Parameters

i:int

Position of element to extract.    Returns
 Series or Index
   Examples
>>> s = pd.Series(["String",
...               (1, 2, 3),
...               ["a", "b", "c"],
...               123,
...               -456,
...               {1: "Hello", "2": "World"}])
>>> s
0                        String
1                     (1, 2, 3)
2                     [a, b, c]
3                           123
4                          -456
5    {1: 'Hello', '2': 'World'}
dtype: object

>>> s.str.get(1)
0        t
1        2
2        b
3      NaN
4      NaN
5    Hello
dtype: object

>>> s.str.get(-1)
0      g
1      3
2      c
3    NaN
4    NaN
5    None
dtype: object


pandas.Series.str.get_dummies   Series.str.get_dummies(sep='|')[source]

Return DataFrame of dummy/indicator variables for Series. Each string in Series is split by sep and returned as a DataFrame of dummy/indicator variables.  Parameters

sep:str, default “|”

String to split on.    Returns
 DataFrame

Dummy variables corresponding to values of the Series.      See also  get_dummies

Convert categorical variable into dummy/indicator variables.    Examples
>>> pd.Series(['a|b', 'a', 'a|c']).str.get_dummies()
   a  b  c
0  1  1  0
1  1  0  0
2  1  0  1

>>> pd.Series(['a|b', np.nan, 'a|c']).str.get_dummies()
   a  b  c
0  1  1  0
1  0  0  0
2  1  0  1


pandas.Series.str.index   Series.str.index(sub, start=0, end=None)[source]

Return lowest indexes in each string in Series/Index. Each of the returned indexes corresponds to the position where the substring is fully contained between [start:end]. This is the same as str.find except instead of returning -1, it raises a ValueError when the substring is not found. Equivalent to standard str.index.  Parameters

sub:str

Substring being searched.
start:int

Left edge index.
end:int

Right edge index.    Returns
 Series or Index of object
    See also  rindex

Return highest indexes in each strings.


pandas.Series.str.isalnum   Series.str.isalnum()[source]

Check whether all characters in each string are alphanumeric. This is equivalent to running the Python string method str.isalnum() for each element of the Series/Index. If a string has zero characters, False is returned for that check.  Returns
 Series or Index of bool

Series or Index of boolean values with the same length as the original Series/Index.      See also  Series.str.isalpha

Check whether all characters are alphabetic.  Series.str.isnumeric

Check whether all characters are numeric.  Series.str.isalnum

Check whether all characters are alphanumeric.  Series.str.isdigit

Check whether all characters are digits.  Series.str.isdecimal

Check whether all characters are decimal.  Series.str.isspace

Check whether all characters are whitespace.  Series.str.islower

Check whether all characters are lowercase.  Series.str.isupper

Check whether all characters are uppercase.  Series.str.istitle

Check whether all characters are titlecase.    Examples Checks for Alphabetic and Numeric Characters
>>> s1 = pd.Series(['one', 'one1', '1', ''])

>>> s1.str.isalpha()
0     True
1    False
2    False
3    False
dtype: bool

>>> s1.str.isnumeric()
0    False
1    False
2     True
3    False
dtype: bool

>>> s1.str.isalnum()
0     True
1     True
2     True
3    False
dtype: bool
  Note that checks against characters mixed with any additional punctuation or whitespace will evaluate to false for an alphanumeric check.
>>> s2 = pd.Series(['A B', '1.5', '3,000'])
>>> s2.str.isalnum()
0    False
1    False
2    False
dtype: bool
  More Detailed Checks for Numeric Characters There are several different but overlapping sets of numeric characters that can be checked for.
>>> s3 = pd.Series(['23', '³', '⅕', ''])
  The s3.str.isdecimal method checks for characters used to form numbers in base 10.
>>> s3.str.isdecimal()
0     True
1    False
2    False
3    False
dtype: bool
  The s.str.isdigit method is the same as s3.str.isdecimal but also includes special digits, like superscripted and subscripted digits in unicode.
>>> s3.str.isdigit()
0     True
1     True
2    False
3    False
dtype: bool
  The s.str.isnumeric method is the same as s3.str.isdigit but also includes other characters that can represent quantities such as unicode fractions.
>>> s3.str.isnumeric()
0     True
1     True
2     True
3    False
dtype: bool
  Checks for Whitespace
>>> s4 = pd.Series([' ', '\t\r\n ', ''])
>>> s4.str.isspace()
0     True
1     True
2    False
dtype: bool
  Checks for Character Case
>>> s5 = pd.Series(['leopard', 'Golden Eagle', 'SNAKE', ''])

>>> s5.str.islower()
0     True
1    False
2    False
3    False
dtype: bool

>>> s5.str.isupper()
0    False
1    False
2     True
3    False
dtype: bool
  The s5.str.istitle method checks for whether all words are in title case (whether only the first letter of each word is capitalized). Words are assumed to be as any sequence of non-numeric characters separated by whitespace characters.
>>> s5.str.istitle()
0    False
1     True
2    False
3    False
dtype: bool


pandas.Series.str.isalpha   Series.str.isalpha()[source]

Check whether all characters in each string are alphabetic. This is equivalent to running the Python string method str.isalpha() for each element of the Series/Index. If a string has zero characters, False is returned for that check.  Returns
 Series or Index of bool

Series or Index of boolean values with the same length as the original Series/Index.      See also  Series.str.isalpha

Check whether all characters are alphabetic.  Series.str.isnumeric

Check whether all characters are numeric.  Series.str.isalnum

Check whether all characters are alphanumeric.  Series.str.isdigit

Check whether all characters are digits.  Series.str.isdecimal

Check whether all characters are decimal.  Series.str.isspace

Check whether all characters are whitespace.  Series.str.islower

Check whether all characters are lowercase.  Series.str.isupper

Check whether all characters are uppercase.  Series.str.istitle

Check whether all characters are titlecase.    Examples Checks for Alphabetic and Numeric Characters
>>> s1 = pd.Series(['one', 'one1', '1', ''])

>>> s1.str.isalpha()
0     True
1    False
2    False
3    False
dtype: bool

>>> s1.str.isnumeric()
0    False
1    False
2     True
3    False
dtype: bool

>>> s1.str.isalnum()
0     True
1     True
2     True
3    False
dtype: bool
  Note that checks against characters mixed with any additional punctuation or whitespace will evaluate to false for an alphanumeric check.
>>> s2 = pd.Series(['A B', '1.5', '3,000'])
>>> s2.str.isalnum()
0    False
1    False
2    False
dtype: bool
  More Detailed Checks for Numeric Characters There are several different but overlapping sets of numeric characters that can be checked for.
>>> s3 = pd.Series(['23', '³', '⅕', ''])
  The s3.str.isdecimal method checks for characters used to form numbers in base 10.
>>> s3.str.isdecimal()
0     True
1    False
2    False
3    False
dtype: bool
  The s.str.isdigit method is the same as s3.str.isdecimal but also includes special digits, like superscripted and subscripted digits in unicode.
>>> s3.str.isdigit()
0     True
1     True
2    False
3    False
dtype: bool
  The s.str.isnumeric method is the same as s3.str.isdigit but also includes other characters that can represent quantities such as unicode fractions.
>>> s3.str.isnumeric()
0     True
1     True
2     True
3    False
dtype: bool
  Checks for Whitespace
>>> s4 = pd.Series([' ', '\t\r\n ', ''])
>>> s4.str.isspace()
0     True
1     True
2    False
dtype: bool
  Checks for Character Case
>>> s5 = pd.Series(['leopard', 'Golden Eagle', 'SNAKE', ''])

>>> s5.str.islower()
0     True
1    False
2    False
3    False
dtype: bool

>>> s5.str.isupper()
0    False
1    False
2     True
3    False
dtype: bool
  The s5.str.istitle method checks for whether all words are in title case (whether only the first letter of each word is capitalized). Words are assumed to be as any sequence of non-numeric characters separated by whitespace characters.
>>> s5.str.istitle()
0    False
1     True
2    False
3    False
dtype: bool


pandas.Series.str.isdecimal   Series.str.isdecimal()[source]

Check whether all characters in each string are decimal. This is equivalent to running the Python string method str.isdecimal() for each element of the Series/Index. If a string has zero characters, False is returned for that check.  Returns
 Series or Index of bool

Series or Index of boolean values with the same length as the original Series/Index.      See also  Series.str.isalpha

Check whether all characters are alphabetic.  Series.str.isnumeric

Check whether all characters are numeric.  Series.str.isalnum

Check whether all characters are alphanumeric.  Series.str.isdigit

Check whether all characters are digits.  Series.str.isdecimal

Check whether all characters are decimal.  Series.str.isspace

Check whether all characters are whitespace.  Series.str.islower

Check whether all characters are lowercase.  Series.str.isupper

Check whether all characters are uppercase.  Series.str.istitle

Check whether all characters are titlecase.    Examples Checks for Alphabetic and Numeric Characters
>>> s1 = pd.Series(['one', 'one1', '1', ''])

>>> s1.str.isalpha()
0     True
1    False
2    False
3    False
dtype: bool

>>> s1.str.isnumeric()
0    False
1    False
2     True
3    False
dtype: bool

>>> s1.str.isalnum()
0     True
1     True
2     True
3    False
dtype: bool
  Note that checks against characters mixed with any additional punctuation or whitespace will evaluate to false for an alphanumeric check.
>>> s2 = pd.Series(['A B', '1.5', '3,000'])
>>> s2.str.isalnum()
0    False
1    False
2    False
dtype: bool
  More Detailed Checks for Numeric Characters There are several different but overlapping sets of numeric characters that can be checked for.
>>> s3 = pd.Series(['23', '³', '⅕', ''])
  The s3.str.isdecimal method checks for characters used to form numbers in base 10.
>>> s3.str.isdecimal()
0     True
1    False
2    False
3    False
dtype: bool
  The s.str.isdigit method is the same as s3.str.isdecimal but also includes special digits, like superscripted and subscripted digits in unicode.
>>> s3.str.isdigit()
0     True
1     True
2    False
3    False
dtype: bool
  The s.str.isnumeric method is the same as s3.str.isdigit but also includes other characters that can represent quantities such as unicode fractions.
>>> s3.str.isnumeric()
0     True
1     True
2     True
3    False
dtype: bool
  Checks for Whitespace
>>> s4 = pd.Series([' ', '\t\r\n ', ''])
>>> s4.str.isspace()
0     True
1     True
2    False
dtype: bool
  Checks for Character Case
>>> s5 = pd.Series(['leopard', 'Golden Eagle', 'SNAKE', ''])

>>> s5.str.islower()
0     True
1    False
2    False
3    False
dtype: bool

>>> s5.str.isupper()
0    False
1    False
2     True
3    False
dtype: bool
  The s5.str.istitle method checks for whether all words are in title case (whether only the first letter of each word is capitalized). Words are assumed to be as any sequence of non-numeric characters separated by whitespace characters.
>>> s5.str.istitle()
0    False
1     True
2    False
3    False
dtype: bool


pandas.Series.str.isdigit   Series.str.isdigit()[source]

Check whether all characters in each string are digits. This is equivalent to running the Python string method str.isdigit() for each element of the Series/Index. If a string has zero characters, False is returned for that check.  Returns
 Series or Index of bool

Series or Index of boolean values with the same length as the original Series/Index.      See also  Series.str.isalpha

Check whether all characters are alphabetic.  Series.str.isnumeric

Check whether all characters are numeric.  Series.str.isalnum

Check whether all characters are alphanumeric.  Series.str.isdigit

Check whether all characters are digits.  Series.str.isdecimal

Check whether all characters are decimal.  Series.str.isspace

Check whether all characters are whitespace.  Series.str.islower

Check whether all characters are lowercase.  Series.str.isupper

Check whether all characters are uppercase.  Series.str.istitle

Check whether all characters are titlecase.    Examples Checks for Alphabetic and Numeric Characters
>>> s1 = pd.Series(['one', 'one1', '1', ''])

>>> s1.str.isalpha()
0     True
1    False
2    False
3    False
dtype: bool

>>> s1.str.isnumeric()
0    False
1    False
2     True
3    False
dtype: bool

>>> s1.str.isalnum()
0     True
1     True
2     True
3    False
dtype: bool
  Note that checks against characters mixed with any additional punctuation or whitespace will evaluate to false for an alphanumeric check.
>>> s2 = pd.Series(['A B', '1.5', '3,000'])
>>> s2.str.isalnum()
0    False
1    False
2    False
dtype: bool
  More Detailed Checks for Numeric Characters There are several different but overlapping sets of numeric characters that can be checked for.
>>> s3 = pd.Series(['23', '³', '⅕', ''])
  The s3.str.isdecimal method checks for characters used to form numbers in base 10.
>>> s3.str.isdecimal()
0     True
1    False
2    False
3    False
dtype: bool
  The s.str.isdigit method is the same as s3.str.isdecimal but also includes special digits, like superscripted and subscripted digits in unicode.
>>> s3.str.isdigit()
0     True
1     True
2    False
3    False
dtype: bool
  The s.str.isnumeric method is the same as s3.str.isdigit but also includes other characters that can represent quantities such as unicode fractions.
>>> s3.str.isnumeric()
0     True
1     True
2     True
3    False
dtype: bool
  Checks for Whitespace
>>> s4 = pd.Series([' ', '\t\r\n ', ''])
>>> s4.str.isspace()
0     True
1     True
2    False
dtype: bool
  Checks for Character Case
>>> s5 = pd.Series(['leopard', 'Golden Eagle', 'SNAKE', ''])

>>> s5.str.islower()
0     True
1    False
2    False
3    False
dtype: bool

>>> s5.str.isupper()
0    False
1    False
2     True
3    False
dtype: bool
  The s5.str.istitle method checks for whether all words are in title case (whether only the first letter of each word is capitalized). Words are assumed to be as any sequence of non-numeric characters separated by whitespace characters.
>>> s5.str.istitle()
0    False
1     True
2    False
3    False
dtype: bool


pandas.Series.str.islower   Series.str.islower()[source]

Check whether all characters in each string are lowercase. This is equivalent to running the Python string method str.islower() for each element of the Series/Index. If a string has zero characters, False is returned for that check.  Returns
 Series or Index of bool

Series or Index of boolean values with the same length as the original Series/Index.      See also  Series.str.isalpha

Check whether all characters are alphabetic.  Series.str.isnumeric

Check whether all characters are numeric.  Series.str.isalnum

Check whether all characters are alphanumeric.  Series.str.isdigit

Check whether all characters are digits.  Series.str.isdecimal

Check whether all characters are decimal.  Series.str.isspace

Check whether all characters are whitespace.  Series.str.islower

Check whether all characters are lowercase.  Series.str.isupper

Check whether all characters are uppercase.  Series.str.istitle

Check whether all characters are titlecase.    Examples Checks for Alphabetic and Numeric Characters
>>> s1 = pd.Series(['one', 'one1', '1', ''])

>>> s1.str.isalpha()
0     True
1    False
2    False
3    False
dtype: bool

>>> s1.str.isnumeric()
0    False
1    False
2     True
3    False
dtype: bool

>>> s1.str.isalnum()
0     True
1     True
2     True
3    False
dtype: bool
  Note that checks against characters mixed with any additional punctuation or whitespace will evaluate to false for an alphanumeric check.
>>> s2 = pd.Series(['A B', '1.5', '3,000'])
>>> s2.str.isalnum()
0    False
1    False
2    False
dtype: bool
  More Detailed Checks for Numeric Characters There are several different but overlapping sets of numeric characters that can be checked for.
>>> s3 = pd.Series(['23', '³', '⅕', ''])
  The s3.str.isdecimal method checks for characters used to form numbers in base 10.
>>> s3.str.isdecimal()
0     True
1    False
2    False
3    False
dtype: bool
  The s.str.isdigit method is the same as s3.str.isdecimal but also includes special digits, like superscripted and subscripted digits in unicode.
>>> s3.str.isdigit()
0     True
1     True
2    False
3    False
dtype: bool
  The s.str.isnumeric method is the same as s3.str.isdigit but also includes other characters that can represent quantities such as unicode fractions.
>>> s3.str.isnumeric()
0     True
1     True
2     True
3    False
dtype: bool
  Checks for Whitespace
>>> s4 = pd.Series([' ', '\t\r\n ', ''])
>>> s4.str.isspace()
0     True
1     True
2    False
dtype: bool
  Checks for Character Case
>>> s5 = pd.Series(['leopard', 'Golden Eagle', 'SNAKE', ''])

>>> s5.str.islower()
0     True
1    False
2    False
3    False
dtype: bool

>>> s5.str.isupper()
0    False
1    False
2     True
3    False
dtype: bool
  The s5.str.istitle method checks for whether all words are in title case (whether only the first letter of each word is capitalized). Words are assumed to be as any sequence of non-numeric characters separated by whitespace characters.
>>> s5.str.istitle()
0    False
1     True
2    False
3    False
dtype: bool


pandas.Series.str.isnumeric   Series.str.isnumeric()[source]

Check whether all characters in each string are numeric. This is equivalent to running the Python string method str.isnumeric() for each element of the Series/Index. If a string has zero characters, False is returned for that check.  Returns
 Series or Index of bool

Series or Index of boolean values with the same length as the original Series/Index.      See also  Series.str.isalpha

Check whether all characters are alphabetic.  Series.str.isnumeric

Check whether all characters are numeric.  Series.str.isalnum

Check whether all characters are alphanumeric.  Series.str.isdigit

Check whether all characters are digits.  Series.str.isdecimal

Check whether all characters are decimal.  Series.str.isspace

Check whether all characters are whitespace.  Series.str.islower

Check whether all characters are lowercase.  Series.str.isupper

Check whether all characters are uppercase.  Series.str.istitle

Check whether all characters are titlecase.    Examples Checks for Alphabetic and Numeric Characters
>>> s1 = pd.Series(['one', 'one1', '1', ''])

>>> s1.str.isalpha()
0     True
1    False
2    False
3    False
dtype: bool

>>> s1.str.isnumeric()
0    False
1    False
2     True
3    False
dtype: bool

>>> s1.str.isalnum()
0     True
1     True
2     True
3    False
dtype: bool
  Note that checks against characters mixed with any additional punctuation or whitespace will evaluate to false for an alphanumeric check.
>>> s2 = pd.Series(['A B', '1.5', '3,000'])
>>> s2.str.isalnum()
0    False
1    False
2    False
dtype: bool
  More Detailed Checks for Numeric Characters There are several different but overlapping sets of numeric characters that can be checked for.
>>> s3 = pd.Series(['23', '³', '⅕', ''])
  The s3.str.isdecimal method checks for characters used to form numbers in base 10.
>>> s3.str.isdecimal()
0     True
1    False
2    False
3    False
dtype: bool
  The s.str.isdigit method is the same as s3.str.isdecimal but also includes special digits, like superscripted and subscripted digits in unicode.
>>> s3.str.isdigit()
0     True
1     True
2    False
3    False
dtype: bool
  The s.str.isnumeric method is the same as s3.str.isdigit but also includes other characters that can represent quantities such as unicode fractions.
>>> s3.str.isnumeric()
0     True
1     True
2     True
3    False
dtype: bool
  Checks for Whitespace
>>> s4 = pd.Series([' ', '\t\r\n ', ''])
>>> s4.str.isspace()
0     True
1     True
2    False
dtype: bool
  Checks for Character Case
>>> s5 = pd.Series(['leopard', 'Golden Eagle', 'SNAKE', ''])

>>> s5.str.islower()
0     True
1    False
2    False
3    False
dtype: bool

>>> s5.str.isupper()
0    False
1    False
2     True
3    False
dtype: bool
  The s5.str.istitle method checks for whether all words are in title case (whether only the first letter of each word is capitalized). Words are assumed to be as any sequence of non-numeric characters separated by whitespace characters.
>>> s5.str.istitle()
0    False
1     True
2    False
3    False
dtype: bool


pandas.Series.str.isspace   Series.str.isspace()[source]

Check whether all characters in each string are whitespace. This is equivalent to running the Python string method str.isspace() for each element of the Series/Index. If a string has zero characters, False is returned for that check.  Returns
 Series or Index of bool

Series or Index of boolean values with the same length as the original Series/Index.      See also  Series.str.isalpha

Check whether all characters are alphabetic.  Series.str.isnumeric

Check whether all characters are numeric.  Series.str.isalnum

Check whether all characters are alphanumeric.  Series.str.isdigit

Check whether all characters are digits.  Series.str.isdecimal

Check whether all characters are decimal.  Series.str.isspace

Check whether all characters are whitespace.  Series.str.islower

Check whether all characters are lowercase.  Series.str.isupper

Check whether all characters are uppercase.  Series.str.istitle

Check whether all characters are titlecase.    Examples Checks for Alphabetic and Numeric Characters
>>> s1 = pd.Series(['one', 'one1', '1', ''])

>>> s1.str.isalpha()
0     True
1    False
2    False
3    False
dtype: bool

>>> s1.str.isnumeric()
0    False
1    False
2     True
3    False
dtype: bool

>>> s1.str.isalnum()
0     True
1     True
2     True
3    False
dtype: bool
  Note that checks against characters mixed with any additional punctuation or whitespace will evaluate to false for an alphanumeric check.
>>> s2 = pd.Series(['A B', '1.5', '3,000'])
>>> s2.str.isalnum()
0    False
1    False
2    False
dtype: bool
  More Detailed Checks for Numeric Characters There are several different but overlapping sets of numeric characters that can be checked for.
>>> s3 = pd.Series(['23', '³', '⅕', ''])
  The s3.str.isdecimal method checks for characters used to form numbers in base 10.
>>> s3.str.isdecimal()
0     True
1    False
2    False
3    False
dtype: bool
  The s.str.isdigit method is the same as s3.str.isdecimal but also includes special digits, like superscripted and subscripted digits in unicode.
>>> s3.str.isdigit()
0     True
1     True
2    False
3    False
dtype: bool
  The s.str.isnumeric method is the same as s3.str.isdigit but also includes other characters that can represent quantities such as unicode fractions.
>>> s3.str.isnumeric()
0     True
1     True
2     True
3    False
dtype: bool
  Checks for Whitespace
>>> s4 = pd.Series([' ', '\t\r\n ', ''])
>>> s4.str.isspace()
0     True
1     True
2    False
dtype: bool
  Checks for Character Case
>>> s5 = pd.Series(['leopard', 'Golden Eagle', 'SNAKE', ''])

>>> s5.str.islower()
0     True
1    False
2    False
3    False
dtype: bool

>>> s5.str.isupper()
0    False
1    False
2     True
3    False
dtype: bool
  The s5.str.istitle method checks for whether all words are in title case (whether only the first letter of each word is capitalized). Words are assumed to be as any sequence of non-numeric characters separated by whitespace characters.
>>> s5.str.istitle()
0    False
1     True
2    False
3    False
dtype: bool


pandas.Series.str.istitle   Series.str.istitle()[source]

Check whether all characters in each string are titlecase. This is equivalent to running the Python string method str.istitle() for each element of the Series/Index. If a string has zero characters, False is returned for that check.  Returns
 Series or Index of bool

Series or Index of boolean values with the same length as the original Series/Index.      See also  Series.str.isalpha

Check whether all characters are alphabetic.  Series.str.isnumeric

Check whether all characters are numeric.  Series.str.isalnum

Check whether all characters are alphanumeric.  Series.str.isdigit

Check whether all characters are digits.  Series.str.isdecimal

Check whether all characters are decimal.  Series.str.isspace

Check whether all characters are whitespace.  Series.str.islower

Check whether all characters are lowercase.  Series.str.isupper

Check whether all characters are uppercase.  Series.str.istitle

Check whether all characters are titlecase.    Examples Checks for Alphabetic and Numeric Characters
>>> s1 = pd.Series(['one', 'one1', '1', ''])

>>> s1.str.isalpha()
0     True
1    False
2    False
3    False
dtype: bool

>>> s1.str.isnumeric()
0    False
1    False
2     True
3    False
dtype: bool

>>> s1.str.isalnum()
0     True
1     True
2     True
3    False
dtype: bool
  Note that checks against characters mixed with any additional punctuation or whitespace will evaluate to false for an alphanumeric check.
>>> s2 = pd.Series(['A B', '1.5', '3,000'])
>>> s2.str.isalnum()
0    False
1    False
2    False
dtype: bool
  More Detailed Checks for Numeric Characters There are several different but overlapping sets of numeric characters that can be checked for.
>>> s3 = pd.Series(['23', '³', '⅕', ''])
  The s3.str.isdecimal method checks for characters used to form numbers in base 10.
>>> s3.str.isdecimal()
0     True
1    False
2    False
3    False
dtype: bool
  The s.str.isdigit method is the same as s3.str.isdecimal but also includes special digits, like superscripted and subscripted digits in unicode.
>>> s3.str.isdigit()
0     True
1     True
2    False
3    False
dtype: bool
  The s.str.isnumeric method is the same as s3.str.isdigit but also includes other characters that can represent quantities such as unicode fractions.
>>> s3.str.isnumeric()
0     True
1     True
2     True
3    False
dtype: bool
  Checks for Whitespace
>>> s4 = pd.Series([' ', '\t\r\n ', ''])
>>> s4.str.isspace()
0     True
1     True
2    False
dtype: bool
  Checks for Character Case
>>> s5 = pd.Series(['leopard', 'Golden Eagle', 'SNAKE', ''])

>>> s5.str.islower()
0     True
1    False
2    False
3    False
dtype: bool

>>> s5.str.isupper()
0    False
1    False
2     True
3    False
dtype: bool
  The s5.str.istitle method checks for whether all words are in title case (whether only the first letter of each word is capitalized). Words are assumed to be as any sequence of non-numeric characters separated by whitespace characters.
>>> s5.str.istitle()
0    False
1     True
2    False
3    False
dtype: bool


pandas.Series.str.isupper   Series.str.isupper()[source]

Check whether all characters in each string are uppercase. This is equivalent to running the Python string method str.isupper() for each element of the Series/Index. If a string has zero characters, False is returned for that check.  Returns
 Series or Index of bool

Series or Index of boolean values with the same length as the original Series/Index.      See also  Series.str.isalpha

Check whether all characters are alphabetic.  Series.str.isnumeric

Check whether all characters are numeric.  Series.str.isalnum

Check whether all characters are alphanumeric.  Series.str.isdigit

Check whether all characters are digits.  Series.str.isdecimal

Check whether all characters are decimal.  Series.str.isspace

Check whether all characters are whitespace.  Series.str.islower

Check whether all characters are lowercase.  Series.str.isupper

Check whether all characters are uppercase.  Series.str.istitle

Check whether all characters are titlecase.    Examples Checks for Alphabetic and Numeric Characters
>>> s1 = pd.Series(['one', 'one1', '1', ''])

>>> s1.str.isalpha()
0     True
1    False
2    False
3    False
dtype: bool

>>> s1.str.isnumeric()
0    False
1    False
2     True
3    False
dtype: bool

>>> s1.str.isalnum()
0     True
1     True
2     True
3    False
dtype: bool
  Note that checks against characters mixed with any additional punctuation or whitespace will evaluate to false for an alphanumeric check.
>>> s2 = pd.Series(['A B', '1.5', '3,000'])
>>> s2.str.isalnum()
0    False
1    False
2    False
dtype: bool
  More Detailed Checks for Numeric Characters There are several different but overlapping sets of numeric characters that can be checked for.
>>> s3 = pd.Series(['23', '³', '⅕', ''])
  The s3.str.isdecimal method checks for characters used to form numbers in base 10.
>>> s3.str.isdecimal()
0     True
1    False
2    False
3    False
dtype: bool
  The s.str.isdigit method is the same as s3.str.isdecimal but also includes special digits, like superscripted and subscripted digits in unicode.
>>> s3.str.isdigit()
0     True
1     True
2    False
3    False
dtype: bool
  The s.str.isnumeric method is the same as s3.str.isdigit but also includes other characters that can represent quantities such as unicode fractions.
>>> s3.str.isnumeric()
0     True
1     True
2     True
3    False
dtype: bool
  Checks for Whitespace
>>> s4 = pd.Series([' ', '\t\r\n ', ''])
>>> s4.str.isspace()
0     True
1     True
2    False
dtype: bool
  Checks for Character Case
>>> s5 = pd.Series(['leopard', 'Golden Eagle', 'SNAKE', ''])

>>> s5.str.islower()
0     True
1    False
2    False
3    False
dtype: bool

>>> s5.str.isupper()
0    False
1    False
2     True
3    False
dtype: bool
  The s5.str.istitle method checks for whether all words are in title case (whether only the first letter of each word is capitalized). Words are assumed to be as any sequence of non-numeric characters separated by whitespace characters.
>>> s5.str.istitle()
0    False
1     True
2    False
3    False
dtype: bool


pandas.Series.str.join   Series.str.join(sep)[source]

Join lists contained as elements in the Series/Index with passed delimiter. If the elements of a Series are lists themselves, join the content of these lists using the delimiter passed to the function. This function is an equivalent to str.join().  Parameters

sep:str

Delimiter to use between list entries.    Returns
 Series/Index: object

The list entries concatenated by intervening occurrences of the delimiter.    Raises
 AttributeError

If the supplied Series contains neither strings nor lists.      See also  str.join

Standard library version of this method.  Series.str.split

Split strings around given separator/delimiter.    Notes If any of the list items is not a string object, the result of the join will be NaN. Examples Example with a list that contains non-string elements.
>>> s = pd.Series([['lion', 'elephant', 'zebra'],
...                [1.1, 2.2, 3.3],
...                ['cat', np.nan, 'dog'],
...                ['cow', 4.5, 'goat'],
...                ['duck', ['swan', 'fish'], 'guppy']])
>>> s
0        [lion, elephant, zebra]
1                [1.1, 2.2, 3.3]
2                [cat, nan, dog]
3               [cow, 4.5, goat]
4    [duck, [swan, fish], guppy]
dtype: object
  Join all lists using a ‘-’. The lists containing object(s) of types other than str will produce a NaN.
>>> s.str.join('-')
0    lion-elephant-zebra
1                    NaN
2                    NaN
3                    NaN
4                    NaN
dtype: object


pandas.Series.str.len   Series.str.len()[source]

Compute the length of each element in the Series/Index. The element may be a sequence (such as a string, tuple or list) or a collection (such as a dictionary).  Returns
 Series or Index of int

A Series or Index of integer values indicating the length of each element in the Series or Index.      See also  str.len

Python built-in function returning the length of an object.  Series.size

Returns the length of the Series.    Examples Returns the length (number of characters) in a string. Returns the number of entries for dictionaries, lists or tuples.
>>> s = pd.Series(['dog',
...                 '',
...                 5,
...                 {'foo' : 'bar'},
...                 [2, 3, 5, 7],
...                 ('one', 'two', 'three')])
>>> s
0                  dog
1
2                    5
3       {'foo': 'bar'}
4         [2, 3, 5, 7]
5    (one, two, three)
dtype: object
>>> s.str.len()
0    3.0
1    0.0
2    NaN
3    1.0
4    4.0
5    3.0
dtype: float64


pandas.Series.str.ljust   Series.str.ljust(width, fillchar=' ')[source]

Pad right side of strings in the Series/Index. Equivalent to str.ljust().  Parameters

width:int

Minimum width of resulting string; additional characters will be filled with fillchar.
fillchar:str

Additional character for filling, default is whitespace.    Returns

filled:Series/Index of objects.


pandas.Series.str.lower   Series.str.lower()[source]

Convert strings in the Series/Index to lowercase. Equivalent to str.lower().  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


pandas.Series.str.lstrip   Series.str.lstrip(to_strip=None)[source]

Remove leading characters. Strip whitespaces (including newlines) or a set of specified characters from each string in the Series/Index from left side. Equivalent to str.lstrip().  Parameters

to_strip:str or None, default None

Specifying the set of characters to be removed. All combinations of this set of characters will be stripped. If None then whitespaces are removed.    Returns
 Series or Index of object
    See also  Series.str.strip

Remove leading and trailing characters in Series/Index.  Series.str.lstrip

Remove leading characters in Series/Index.  Series.str.rstrip

Remove trailing characters in Series/Index.    Examples
>>> s = pd.Series(['1. Ant.  ', '2. Bee!\n', '3. Cat?\t', np.nan])
>>> s
0    1. Ant.
1    2. Bee!\n
2    3. Cat?\t
3          NaN
dtype: object

>>> s.str.strip()
0    1. Ant.
1    2. Bee!
2    3. Cat?
3        NaN
dtype: object

>>> s.str.lstrip('123.')
0    Ant.
1    Bee!\n
2    Cat?\t
3       NaN
dtype: object

>>> s.str.rstrip('.!? \n\t')
0    1. Ant
1    2. Bee
2    3. Cat
3       NaN
dtype: object

>>> s.str.strip('123.!? \n\t')
0    Ant
1    Bee
2    Cat
3    NaN
dtype: object


pandas.Series.str.match   Series.str.match(pat, case=True, flags=0, na=None)[source]

Determine if each string starts with a match of a regular expression.  Parameters

pat:str

Character sequence or regular expression.
case:bool, default True

If True, case sensitive.
flags:int, default 0 (no flags)

Regex module flags, e.g. re.IGNORECASE.
na:scalar, optional

Fill value for missing values. The default depends on dtype of the array. For object-dtype, numpy.nan is used. For StringDtype, pandas.NA is used.    Returns
 Series/Index/array of boolean values
    See also  fullmatch

Stricter matching that requires the entire string to match.  contains

Analogous, but less strict, relying on re.search instead of re.match.  extract

Extract matched groups.


pandas.Series.str.normalize   Series.str.normalize(form)[source]

Return the Unicode normal form for the strings in the Series/Index. For more information on the forms, see the unicodedata.normalize().  Parameters

form:{‘NFC’, ‘NFKC’, ‘NFD’, ‘NFKD’}

Unicode form.    Returns

normalized:Series/Index of objects


pandas.Series.str.pad   Series.str.pad(width, side='left', fillchar=' ')[source]

Pad strings in the Series/Index up to width.  Parameters

width:int

Minimum width of resulting string; additional characters will be filled with character defined in fillchar.
side:{‘left’, ‘right’, ‘both’}, default ‘left’

Side from which to fill resulting string.
fillchar:str, default ‘ ‘

Additional character for filling, default is whitespace.    Returns
 Series or Index of object

Returns Series or Index with minimum number of char in object.      See also  Series.str.rjust

Fills the left side of strings with an arbitrary character. Equivalent to Series.str.pad(side='left').  Series.str.ljust

Fills the right side of strings with an arbitrary character. Equivalent to Series.str.pad(side='right').  Series.str.center

Fills both sides of strings with an arbitrary character. Equivalent to Series.str.pad(side='both').  Series.str.zfill

Pad strings in the Series/Index by prepending ‘0’ character. Equivalent to Series.str.pad(side='left', fillchar='0').    Examples
>>> s = pd.Series(["caribou", "tiger"])
>>> s
0    caribou
1      tiger
dtype: object

>>> s.str.pad(width=10)
0       caribou
1         tiger
dtype: object

>>> s.str.pad(width=10, side='right', fillchar='-')
0    caribou---
1    tiger-----
dtype: object

>>> s.str.pad(width=10, side='both', fillchar='-')
0    -caribou--
1    --tiger---
dtype: object


pandas.Series.str.partition   Series.str.partition(sep=' ', expand=True)[source]

Split the string at the first occurrence of sep. This method splits the string at the first occurrence of sep, and returns 3 elements containing the part before the separator, the separator itself, and the part after the separator. If the separator is not found, return 3 elements containing the string itself, followed by two empty strings.  Parameters

sep:str, default whitespace

String to split on.
expand:bool, default True

If True, return DataFrame/MultiIndex expanding dimensionality. If False, return Series/Index.    Returns
 DataFrame/MultiIndex or Series/Index of objects
    See also  rpartition

Split the string at the last occurrence of sep.  Series.str.split

Split strings around given separators.  str.partition

Standard library version.    Examples
>>> s = pd.Series(['Linda van der Berg', 'George Pitt-Rivers'])
>>> s
0    Linda van der Berg
1    George Pitt-Rivers
dtype: object

>>> s.str.partition()
        0  1             2
0   Linda     van der Berg
1  George      Pitt-Rivers
  To partition by the last space instead of the first one:
>>> s.str.rpartition()
               0  1            2
0  Linda van der            Berg
1         George     Pitt-Rivers
  To partition by something different than a space:
>>> s.str.partition('-')
                    0  1       2
0  Linda van der Berg
1         George Pitt  -  Rivers
  To return a Series containing tuples instead of a DataFrame:
>>> s.str.partition('-', expand=False)
0    (Linda van der Berg, , )
1    (George Pitt, -, Rivers)
dtype: object
  Also available on indices:
>>> idx = pd.Index(['X 123', 'Y 999'])
>>> idx
Index(['X 123', 'Y 999'], dtype='object')
  Which will create a MultiIndex:
>>> idx.str.partition()
MultiIndex([('X', ' ', '123'),
            ('Y', ' ', '999')],
           )
  Or an index with tuples with expand=False:
>>> idx.str.partition(expand=False)
Index([('X', ' ', '123'), ('Y', ' ', '999')], dtype='object')


pandas.Series.str.removeprefix   Series.str.removeprefix(prefix)[source]

Remove a prefix from an object series. If the prefix is not present, the original string will be returned.  Parameters

prefix:str

Remove the prefix of the string.    Returns
 Series/Index: object

The Series or Index with given prefix removed.      See also  Series.str.removesuffix

Remove a suffix from an object series.    Examples
>>> s = pd.Series(["str_foo", "str_bar", "no_prefix"])
>>> s
0    str_foo
1    str_bar
2    no_prefix
dtype: object
>>> s.str.removeprefix("str_")
0    foo
1    bar
2    no_prefix
dtype: object

>>> s = pd.Series(["foo_str", "bar_str", "no_suffix"])
>>> s
0    foo_str
1    bar_str
2    no_suffix
dtype: object
>>> s.str.removesuffix("_str")
0    foo
1    bar
2    no_suffix
dtype: object


pandas.Series.str.removesuffix   Series.str.removesuffix(suffix)[source]

Remove a suffix from an object series. If the suffix is not present, the original string will be returned.  Parameters

suffix:str

Remove the suffix of the string.    Returns
 Series/Index: object

The Series or Index with given suffix removed.      See also  Series.str.removeprefix

Remove a prefix from an object series.    Examples
>>> s = pd.Series(["str_foo", "str_bar", "no_prefix"])
>>> s
0    str_foo
1    str_bar
2    no_prefix
dtype: object
>>> s.str.removeprefix("str_")
0    foo
1    bar
2    no_prefix
dtype: object

>>> s = pd.Series(["foo_str", "bar_str", "no_suffix"])
>>> s
0    foo_str
1    bar_str
2    no_suffix
dtype: object
>>> s.str.removesuffix("_str")
0    foo
1    bar
2    no_suffix
dtype: object


pandas.Series.str.repeat   Series.str.repeat(repeats)[source]

Duplicate each string in the Series or Index.  Parameters

repeats:int or sequence of int

Same value for all (int) or different value per (sequence).    Returns
 Series or Index of object

Series or Index of repeated string objects specified by input parameter repeats.     Examples
>>> s = pd.Series(['a', 'b', 'c'])
>>> s
0    a
1    b
2    c
dtype: object
  Single int repeats string in Series
>>> s.str.repeat(repeats=2)
0    aa
1    bb
2    cc
dtype: object
  Sequence of int repeats corresponding string in Series
>>> s.str.repeat(repeats=[1, 2, 3])
0      a
1     bb
2    ccc
dtype: object


pandas.Series.str.replace   Series.str.replace(pat, repl, n=- 1, case=None, flags=0, regex=None)[source]

Replace each occurrence of pattern/regex in the Series/Index. Equivalent to str.replace() or re.sub(), depending on the regex value.  Parameters

pat:str or compiled regex

String can be a character sequence or regular expression.
repl:str or callable

Replacement string or a callable. The callable is passed the regex match object and must return a replacement string to be used. See re.sub().
n:int, default -1 (all)

Number of replacements to make from start.
case:bool, default None

Determines if replace is case sensitive:  If True, case sensitive (the default if pat is a string) Set to False for case insensitive Cannot be set if pat is a compiled regex.
flags:int, default 0 (no flags)

Regex module flags, e.g. re.IGNORECASE. Cannot be set if pat is a compiled regex.
regex:bool, default True

Determines if the passed-in pattern is a regular expression:  If True, assumes the passed-in pattern is a regular expression. If False, treats the pattern as a literal string Cannot be set to False if pat is a compiled regex or repl is a callable.   New in version 0.23.0.     Returns
 Series or Index of object

A copy of the object with all matching occurrences of pat replaced by repl.    Raises
 ValueError

 if regex is False and repl is a callable or pat is a compiled regex if pat is a compiled regex and case or flags is set      Notes When pat is a compiled regex, all flags should be included in the compiled regex. Use of case, flags, or regex=False with a compiled regex will raise an error. Examples When pat is a string and regex is True (the default), the given pat is compiled as a regex. When repl is a string, it replaces matching regex patterns as with re.sub(). NaN value(s) in the Series are left as is:
>>> pd.Series(['foo', 'fuz', np.nan]).str.replace('f.', 'ba', regex=True)
0    bao
1    baz
2    NaN
dtype: object
  When pat is a string and regex is False, every pat is replaced with repl as with str.replace():
>>> pd.Series(['f.o', 'fuz', np.nan]).str.replace('f.', 'ba', regex=False)
0    bao
1    fuz
2    NaN
dtype: object
  When repl is a callable, it is called on every pat using re.sub(). The callable should expect one positional argument (a regex object) and return a string. To get the idea:
>>> pd.Series(['foo', 'fuz', np.nan]).str.replace('f', repr, regex=True)
0    <re.Match object; span=(0, 1), match='f'>oo
1    <re.Match object; span=(0, 1), match='f'>uz
2                                            NaN
dtype: object
  Reverse every lowercase alphabetic word:
>>> repl = lambda m: m.group(0)[::-1]
>>> ser = pd.Series(['foo 123', 'bar baz', np.nan])
>>> ser.str.replace(r'[a-z]+', repl, regex=True)
0    oof 123
1    rab zab
2        NaN
dtype: object
  Using regex groups (extract second group and swap case):
>>> pat = r"(?P<one>\w+) (?P<two>\w+) (?P<three>\w+)"
>>> repl = lambda m: m.group('two').swapcase()
>>> ser = pd.Series(['One Two Three', 'Foo Bar Baz'])
>>> ser.str.replace(pat, repl, regex=True)
0    tWO
1    bAR
dtype: object
  Using a compiled regex with flags
>>> import re
>>> regex_pat = re.compile(r'FUZ', flags=re.IGNORECASE)
>>> pd.Series(['foo', 'fuz', np.nan]).str.replace(regex_pat, 'bar', regex=True)
0    foo
1    bar
2    NaN
dtype: object


pandas.Series.str.rfind   Series.str.rfind(sub, start=0, end=None)[source]

Return highest indexes in each strings in the Series/Index. Each of returned indexes corresponds to the position where the substring is fully contained between [start:end]. Return -1 on failure. Equivalent to standard str.rfind().  Parameters

sub:str

Substring being searched.
start:int

Left edge index.
end:int

Right edge index.    Returns
 Series or Index of int.
    See also  find

Return lowest indexes in each strings.


pandas.Series.str.rindex   Series.str.rindex(sub, start=0, end=None)[source]

Return highest indexes in each string in Series/Index. Each of the returned indexes corresponds to the position where the substring is fully contained between [start:end]. This is the same as str.rfind except instead of returning -1, it raises a ValueError when the substring is not found. Equivalent to standard str.rindex.  Parameters

sub:str

Substring being searched.
start:int

Left edge index.
end:int

Right edge index.    Returns
 Series or Index of object
    See also  index

Return lowest indexes in each strings.


pandas.Series.str.rjust   Series.str.rjust(width, fillchar=' ')[source]

Pad left side of strings in the Series/Index. Equivalent to str.rjust().  Parameters

width:int

Minimum width of resulting string; additional characters will be filled with fillchar.
fillchar:str

Additional character for filling, default is whitespace.    Returns

filled:Series/Index of objects.


pandas.Series.str.rpartition   Series.str.rpartition(sep=' ', expand=True)[source]

Split the string at the last occurrence of sep. This method splits the string at the last occurrence of sep, and returns 3 elements containing the part before the separator, the separator itself, and the part after the separator. If the separator is not found, return 3 elements containing two empty strings, followed by the string itself.  Parameters

sep:str, default whitespace

String to split on.
expand:bool, default True

If True, return DataFrame/MultiIndex expanding dimensionality. If False, return Series/Index.    Returns
 DataFrame/MultiIndex or Series/Index of objects
    See also  partition

Split the string at the first occurrence of sep.  Series.str.split

Split strings around given separators.  str.partition

Standard library version.    Examples
>>> s = pd.Series(['Linda van der Berg', 'George Pitt-Rivers'])
>>> s
0    Linda van der Berg
1    George Pitt-Rivers
dtype: object

>>> s.str.partition()
        0  1             2
0   Linda     van der Berg
1  George      Pitt-Rivers
  To partition by the last space instead of the first one:
>>> s.str.rpartition()
               0  1            2
0  Linda van der            Berg
1         George     Pitt-Rivers
  To partition by something different than a space:
>>> s.str.partition('-')
                    0  1       2
0  Linda van der Berg
1         George Pitt  -  Rivers
  To return a Series containing tuples instead of a DataFrame:
>>> s.str.partition('-', expand=False)
0    (Linda van der Berg, , )
1    (George Pitt, -, Rivers)
dtype: object
  Also available on indices:
>>> idx = pd.Index(['X 123', 'Y 999'])
>>> idx
Index(['X 123', 'Y 999'], dtype='object')
  Which will create a MultiIndex:
>>> idx.str.partition()
MultiIndex([('X', ' ', '123'),
            ('Y', ' ', '999')],
           )
  Or an index with tuples with expand=False:
>>> idx.str.partition(expand=False)
Index([('X', ' ', '123'), ('Y', ' ', '999')], dtype='object')


pandas.Series.str.rsplit   Series.str.rsplit(pat=None, n=- 1, expand=False)[source]

Split strings around given separator/delimiter. Splits the string in the Series/Index from the end, at the specified delimiter string.  Parameters

pat:str or compiled regex, optional

String or regular expression to split on. If not specified, split on whitespace.
n:int, default -1 (all)

Limit number of splits in output. None, 0 and -1 will be interpreted as return all splits.
expand:bool, default False

Expand the split strings into separate columns.  If True, return DataFrame/MultiIndex expanding dimensionality. If False, return Series/Index, containing lists of strings.
regex:bool, default None

Determines if the passed-in pattern is a regular expression:  If True, assumes the passed-in pattern is a regular expression If False, treats the pattern as a literal string. If None and pat length is 1, treats pat as a literal string. If None and pat length is not 1, treats pat as a regular expression. Cannot be set to False if pat is a compiled regex   New in version 1.4.0.     Returns
 Series, Index, DataFrame or MultiIndex

Type matches caller unless expand=True (see Notes).    Raises
 ValueError

 if regex is False and pat is a compiled regex       See also  Series.str.split

Split strings around given separator/delimiter.  Series.str.rsplit

Splits string around given separator/delimiter, starting from the right.  Series.str.join

Join lists contained as elements in the Series/Index with passed delimiter.  str.split

Standard library version for split.  str.rsplit

Standard library version for rsplit.    Notes The handling of the n keyword depends on the number of found splits:  If found splits > n, make first n splits only If found splits <= n, make all splits If for a certain row the number of found splits < n, append None for padding up to n if expand=True  If using expand=True, Series and Index callers return DataFrame and MultiIndex objects, respectively. Use of regex=False with a pat as a compiled regex will raise an error. Examples
>>> s = pd.Series(
...     [
...         "this is a regular sentence",
...         "https://docs.python.org/3/tutorial/index.html",
...         np.nan
...     ]
... )
>>> s
0                       this is a regular sentence
1    https://docs.python.org/3/tutorial/index.html
2                                              NaN
dtype: object
  In the default setting, the string is split by whitespace.
>>> s.str.split()
0                   [this, is, a, regular, sentence]
1    [https://docs.python.org/3/tutorial/index.html]
2                                                NaN
dtype: object
  Without the n parameter, the outputs of rsplit and split are identical.
>>> s.str.rsplit()
0                   [this, is, a, regular, sentence]
1    [https://docs.python.org/3/tutorial/index.html]
2                                                NaN
dtype: object
  The n parameter can be used to limit the number of splits on the delimiter. The outputs of split and rsplit are different.
>>> s.str.split(n=2)
0                     [this, is, a regular sentence]
1    [https://docs.python.org/3/tutorial/index.html]
2                                                NaN
dtype: object

>>> s.str.rsplit(n=2)
0                     [this is a, regular, sentence]
1    [https://docs.python.org/3/tutorial/index.html]
2                                                NaN
dtype: object
  The pat parameter can be used to split by other characters.
>>> s.str.split(pat="/")
0                         [this is a regular sentence]
1    [https:, , docs.python.org, 3, tutorial, index...
2                                                  NaN
dtype: object
  When using expand=True, the split elements will expand out into separate columns. If NaN is present, it is propagated throughout the columns during the split.
>>> s.str.split(expand=True)
                                               0     1     2        3         4
0                                           this    is     a  regular  sentence
1  https://docs.python.org/3/tutorial/index.html  None  None     None      None
2                                            NaN   NaN   NaN      NaN       NaN
  For slightly more complex use cases like splitting the html document name from a url, a combination of parameter settings can be used.
>>> s.str.rsplit("/", n=1, expand=True)
                                    0           1
0          this is a regular sentence        None
1  https://docs.python.org/3/tutorial  index.html
2                                 NaN         NaN
  Remember to escape special characters when explicitly using regular expressions.
>>> s = pd.Series(["foo and bar plus baz"])
>>> s.str.split(r"and|plus", expand=True)
    0   1   2
0 foo bar baz
  Regular expressions can be used to handle urls or file names. When pat is a string and regex=None (the default), the given pat is compiled as a regex only if len(pat) != 1.
>>> s = pd.Series(['foojpgbar.jpg'])
>>> s.str.split(r".", expand=True)
           0    1
0  foojpgbar  jpg

>>> s.str.split(r"\.jpg", expand=True)
           0 1
0  foojpgbar
  When regex=True, pat is interpreted as a regex
>>> s.str.split(r"\.jpg", regex=True, expand=True)
           0 1
0  foojpgbar
  A compiled regex can be passed as pat
>>> import re
>>> s.str.split(re.compile(r"\.jpg"), expand=True)
           0 1
0  foojpgbar
  When regex=False, pat is interpreted as the string itself
>>> s.str.split(r"\.jpg", regex=False, expand=True)
               0
0  foojpgbar.jpg


pandas.Series.str.rstrip   Series.str.rstrip(to_strip=None)[source]

Remove trailing characters. Strip whitespaces (including newlines) or a set of specified characters from each string in the Series/Index from right side. Equivalent to str.rstrip().  Parameters

to_strip:str or None, default None

Specifying the set of characters to be removed. All combinations of this set of characters will be stripped. If None then whitespaces are removed.    Returns
 Series or Index of object
    See also  Series.str.strip

Remove leading and trailing characters in Series/Index.  Series.str.lstrip

Remove leading characters in Series/Index.  Series.str.rstrip

Remove trailing characters in Series/Index.    Examples
>>> s = pd.Series(['1. Ant.  ', '2. Bee!\n', '3. Cat?\t', np.nan])
>>> s
0    1. Ant.
1    2. Bee!\n
2    3. Cat?\t
3          NaN
dtype: object

>>> s.str.strip()
0    1. Ant.
1    2. Bee!
2    3. Cat?
3        NaN
dtype: object

>>> s.str.lstrip('123.')
0    Ant.
1    Bee!\n
2    Cat?\t
3       NaN
dtype: object

>>> s.str.rstrip('.!? \n\t')
0    1. Ant
1    2. Bee
2    3. Cat
3       NaN
dtype: object

>>> s.str.strip('123.!? \n\t')
0    Ant
1    Bee
2    Cat
3    NaN
dtype: object


pandas.Series.str.slice   Series.str.slice(start=None, stop=None, step=None)[source]

Slice substrings from each element in the Series or Index.  Parameters

start:int, optional

Start position for slice operation.
stop:int, optional

Stop position for slice operation.
step:int, optional

Step size for slice operation.    Returns
 Series or Index of object

Series or Index from sliced substring from original string object.      See also  Series.str.slice_replace

Replace a slice with a string.  Series.str.get

Return element at position. Equivalent to Series.str.slice(start=i, stop=i+1) with i being the position.    Examples
>>> s = pd.Series(["koala", "dog", "chameleon"])
>>> s
0        koala
1          dog
2    chameleon
dtype: object

>>> s.str.slice(start=1)
0        oala
1          og
2    hameleon
dtype: object

>>> s.str.slice(start=-1)
0           a
1           g
2           n
dtype: object

>>> s.str.slice(stop=2)
0    ko
1    do
2    ch
dtype: object

>>> s.str.slice(step=2)
0      kaa
1       dg
2    caeen
dtype: object

>>> s.str.slice(start=0, stop=5, step=3)
0    kl
1     d
2    cm
dtype: object
  Equivalent behaviour to:
>>> s.str[0:5:3]
0    kl
1     d
2    cm
dtype: object


pandas.Series.str.slice_replace   Series.str.slice_replace(start=None, stop=None, repl=None)[source]

Replace a positional slice of a string with another value.  Parameters

start:int, optional

Left index position to use for the slice. If not specified (None), the slice is unbounded on the left, i.e. slice from the start of the string.
stop:int, optional

Right index position to use for the slice. If not specified (None), the slice is unbounded on the right, i.e. slice until the end of the string.
repl:str, optional

String for replacement. If not specified (None), the sliced region is replaced with an empty string.    Returns
 Series or Index

Same type as the original object.      See also  Series.str.slice

Just slicing without replacement.    Examples
>>> s = pd.Series(['a', 'ab', 'abc', 'abdc', 'abcde'])
>>> s
0        a
1       ab
2      abc
3     abdc
4    abcde
dtype: object
  Specify just start, meaning replace start until the end of the string with repl.
>>> s.str.slice_replace(1, repl='X')
0    aX
1    aX
2    aX
3    aX
4    aX
dtype: object
  Specify just stop, meaning the start of the string to stop is replaced with repl, and the rest of the string is included.
>>> s.str.slice_replace(stop=2, repl='X')
0       X
1       X
2      Xc
3     Xdc
4    Xcde
dtype: object
  Specify start and stop, meaning the slice from start to stop is replaced with repl. Everything before or after start and stop is included as is.
>>> s.str.slice_replace(start=1, stop=3, repl='X')
0      aX
1      aX
2      aX
3     aXc
4    aXde
dtype: object


pandas.Series.str.split   Series.str.split(pat=None, n=- 1, expand=False, *, regex=None)[source]

Split strings around given separator/delimiter. Splits the string in the Series/Index from the beginning, at the specified delimiter string.  Parameters

pat:str or compiled regex, optional

String or regular expression to split on. If not specified, split on whitespace.
n:int, default -1 (all)

Limit number of splits in output. None, 0 and -1 will be interpreted as return all splits.
expand:bool, default False

Expand the split strings into separate columns.  If True, return DataFrame/MultiIndex expanding dimensionality. If False, return Series/Index, containing lists of strings.
regex:bool, default None

Determines if the passed-in pattern is a regular expression:  If True, assumes the passed-in pattern is a regular expression If False, treats the pattern as a literal string. If None and pat length is 1, treats pat as a literal string. If None and pat length is not 1, treats pat as a regular expression. Cannot be set to False if pat is a compiled regex   New in version 1.4.0.     Returns
 Series, Index, DataFrame or MultiIndex

Type matches caller unless expand=True (see Notes).    Raises
 ValueError

 if regex is False and pat is a compiled regex       See also  Series.str.split

Split strings around given separator/delimiter.  Series.str.rsplit

Splits string around given separator/delimiter, starting from the right.  Series.str.join

Join lists contained as elements in the Series/Index with passed delimiter.  str.split

Standard library version for split.  str.rsplit

Standard library version for rsplit.    Notes The handling of the n keyword depends on the number of found splits:  If found splits > n, make first n splits only If found splits <= n, make all splits If for a certain row the number of found splits < n, append None for padding up to n if expand=True  If using expand=True, Series and Index callers return DataFrame and MultiIndex objects, respectively. Use of regex=False with a pat as a compiled regex will raise an error. Examples
>>> s = pd.Series(
...     [
...         "this is a regular sentence",
...         "https://docs.python.org/3/tutorial/index.html",
...         np.nan
...     ]
... )
>>> s
0                       this is a regular sentence
1    https://docs.python.org/3/tutorial/index.html
2                                              NaN
dtype: object
  In the default setting, the string is split by whitespace.
>>> s.str.split()
0                   [this, is, a, regular, sentence]
1    [https://docs.python.org/3/tutorial/index.html]
2                                                NaN
dtype: object
  Without the n parameter, the outputs of rsplit and split are identical.
>>> s.str.rsplit()
0                   [this, is, a, regular, sentence]
1    [https://docs.python.org/3/tutorial/index.html]
2                                                NaN
dtype: object
  The n parameter can be used to limit the number of splits on the delimiter. The outputs of split and rsplit are different.
>>> s.str.split(n=2)
0                     [this, is, a regular sentence]
1    [https://docs.python.org/3/tutorial/index.html]
2                                                NaN
dtype: object

>>> s.str.rsplit(n=2)
0                     [this is a, regular, sentence]
1    [https://docs.python.org/3/tutorial/index.html]
2                                                NaN
dtype: object
  The pat parameter can be used to split by other characters.
>>> s.str.split(pat="/")
0                         [this is a regular sentence]
1    [https:, , docs.python.org, 3, tutorial, index...
2                                                  NaN
dtype: object
  When using expand=True, the split elements will expand out into separate columns. If NaN is present, it is propagated throughout the columns during the split.
>>> s.str.split(expand=True)
                                               0     1     2        3         4
0                                           this    is     a  regular  sentence
1  https://docs.python.org/3/tutorial/index.html  None  None     None      None
2                                            NaN   NaN   NaN      NaN       NaN
  For slightly more complex use cases like splitting the html document name from a url, a combination of parameter settings can be used.
>>> s.str.rsplit("/", n=1, expand=True)
                                    0           1
0          this is a regular sentence        None
1  https://docs.python.org/3/tutorial  index.html
2                                 NaN         NaN
  Remember to escape special characters when explicitly using regular expressions.
>>> s = pd.Series(["foo and bar plus baz"])
>>> s.str.split(r"and|plus", expand=True)
    0   1   2
0 foo bar baz
  Regular expressions can be used to handle urls or file names. When pat is a string and regex=None (the default), the given pat is compiled as a regex only if len(pat) != 1.
>>> s = pd.Series(['foojpgbar.jpg'])
>>> s.str.split(r".", expand=True)
           0    1
0  foojpgbar  jpg

>>> s.str.split(r"\.jpg", expand=True)
           0 1
0  foojpgbar
  When regex=True, pat is interpreted as a regex
>>> s.str.split(r"\.jpg", regex=True, expand=True)
           0 1
0  foojpgbar
  A compiled regex can be passed as pat
>>> import re
>>> s.str.split(re.compile(r"\.jpg"), expand=True)
           0 1
0  foojpgbar
  When regex=False, pat is interpreted as the string itself
>>> s.str.split(r"\.jpg", regex=False, expand=True)
               0
0  foojpgbar.jpg


pandas.Series.str.startswith   Series.str.startswith(pat, na=None)[source]

Test if the start of each string element matches a pattern. Equivalent to str.startswith().  Parameters

pat:str

Character sequence. Regular expressions are not accepted.
na:object, default NaN

Object shown if element tested is not a string. The default depends on dtype of the array. For object-dtype, numpy.nan is used. For StringDtype, pandas.NA is used.    Returns
 Series or Index of bool

A Series of booleans indicating whether the given pattern matches the start of each string element.      See also  str.startswith

Python standard library string method.  Series.str.endswith

Same as startswith, but tests the end of string.  Series.str.contains

Tests if string element contains a pattern.    Examples
>>> s = pd.Series(['bat', 'Bear', 'cat', np.nan])
>>> s
0     bat
1    Bear
2     cat
3     NaN
dtype: object

>>> s.str.startswith('b')
0     True
1    False
2    False
3      NaN
dtype: object
  Specifying na to be False instead of NaN.
>>> s.str.startswith('b', na=False)
0     True
1    False
2    False
3    False
dtype: bool


pandas.Series.str.strip   Series.str.strip(to_strip=None)[source]

Remove leading and trailing characters. Strip whitespaces (including newlines) or a set of specified characters from each string in the Series/Index from left and right sides. Equivalent to str.strip().  Parameters

to_strip:str or None, default None

Specifying the set of characters to be removed. All combinations of this set of characters will be stripped. If None then whitespaces are removed.    Returns
 Series or Index of object
    See also  Series.str.strip

Remove leading and trailing characters in Series/Index.  Series.str.lstrip

Remove leading characters in Series/Index.  Series.str.rstrip

Remove trailing characters in Series/Index.    Examples
>>> s = pd.Series(['1. Ant.  ', '2. Bee!\n', '3. Cat?\t', np.nan])
>>> s
0    1. Ant.
1    2. Bee!\n
2    3. Cat?\t
3          NaN
dtype: object

>>> s.str.strip()
0    1. Ant.
1    2. Bee!
2    3. Cat?
3        NaN
dtype: object

>>> s.str.lstrip('123.')
0    Ant.
1    Bee!\n
2    Cat?\t
3       NaN
dtype: object

>>> s.str.rstrip('.!? \n\t')
0    1. Ant
1    2. Bee
2    3. Cat
3       NaN
dtype: object

>>> s.str.strip('123.!? \n\t')
0    Ant
1    Bee
2    Cat
3    NaN
dtype: object


pandas.Series.str.swapcase   Series.str.swapcase()[source]

Convert strings in the Series/Index to be swapcased. Equivalent to str.swapcase().  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


pandas.Series.str.title   Series.str.title()[source]

Convert strings in the Series/Index to titlecase. Equivalent to str.title().  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


pandas.Series.str.translate   Series.str.translate(table)[source]

Map all characters in the string through the given mapping table. Equivalent to standard str.translate().  Parameters

table:dict

Table is a mapping of Unicode ordinals to Unicode ordinals, strings, or None. Unmapped characters are left untouched. Characters mapped to None are deleted. str.maketrans() is a helper function for making translation tables.    Returns
 Series or Index


pandas.Series.str.upper   Series.str.upper()[source]

Convert strings in the Series/Index to uppercase. Equivalent to str.upper().  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


pandas.Series.str.wrap   Series.str.wrap(width, **kwargs)[source]

Wrap strings in Series/Index at specified line width. This method has the same keyword parameters and defaults as textwrap.TextWrapper.  Parameters

width:int

Maximum line width.
expand_tabs:bool, optional

If True, tab characters will be expanded to spaces (default: True).
replace_whitespace:bool, optional

If True, each whitespace character (as defined by string.whitespace) remaining after tab expansion will be replaced by a single space (default: True).
drop_whitespace:bool, optional

If True, whitespace that, after wrapping, happens to end up at the beginning or end of a line is dropped (default: True).
break_long_words:bool, optional

If True, then words longer than width will be broken in order to ensure that no lines are longer than width. If it is false, long words will not be broken, and some lines may be longer than width (default: True).
break_on_hyphens:bool, optional

If True, wrapping will occur preferably on whitespace and right after hyphens in compound words, as it is customary in English. If false, only whitespaces will be considered as potentially good places for line breaks, but you need to set break_long_words to false if you want truly insecable words (default: True).    Returns
 Series or Index
   Notes Internally, this method uses a textwrap.TextWrapper instance with default settings. To achieve behavior matching R’s stringr library str_wrap function, use the arguments:  expand_tabs = False replace_whitespace = True drop_whitespace = True break_long_words = False break_on_hyphens = False  Examples
>>> s = pd.Series(['line to be wrapped', 'another line to be wrapped'])
>>> s.str.wrap(12)
0             line to be\nwrapped
1    another line\nto be\nwrapped
dtype: object


pandas.Series.str.zfill   Series.str.zfill(width)[source]

Pad strings in the Series/Index by prepending ‘0’ characters. Strings in the Series/Index are padded with ‘0’ characters on the left of the string to reach a total string length width. Strings in the Series/Index with length greater or equal to width are unchanged.  Parameters

width:int

Minimum length of resulting string; strings with length less than width be prepended with ‘0’ characters.    Returns
 Series/Index of objects.
    See also  Series.str.rjust

Fills the left side of strings with an arbitrary character.  Series.str.ljust

Fills the right side of strings with an arbitrary character.  Series.str.pad

Fills the specified sides of strings with an arbitrary character.  Series.str.center

Fills both sides of strings with an arbitrary character.    Notes Differs from str.zfill() which has special handling for ‘+’/’-’ in the string. Examples
>>> s = pd.Series(['-1', '1', '1000', 10, np.nan])
>>> s
0      -1
1       1
2    1000
3      10
4     NaN
dtype: object
  Note that 10 and NaN are not strings, therefore they are converted to NaN. The minus sign in '-1' is treated as a regular character and the zero is added to the left of it (str.zfill() would have moved it to the left). 1000 remains unchanged as it is longer than width.
>>> s.str.zfill(3)
0     0-1
1     001
2    1000
3     NaN
4     NaN
dtype: object


pandas.Series.sub   Series.sub(other, level=None, fill_value=None, axis=0)[source]

Return Subtraction of series and other, element-wise (binary operator sub). Equivalent to series - other, but with support to substitute a fill_value for missing data in either one of the inputs.  Parameters

other:Series or scalar value

fill_value:None or float value, default None (NaN)

Fill existing missing (NaN) values, and any new element needed for successful Series alignment, with this value before computation. If data in both corresponding Series locations is missing the result of filling (at that location) will be missing.
level:int or name

Broadcast across a level, matching Index values on the passed MultiIndex level.    Returns
 Series

The result of the operation.      See also  Series.rsub

Reverse of the Subtraction operator, see Python documentation for more details.    Examples
>>> a = pd.Series([1, 1, 1, np.nan], index=['a', 'b', 'c', 'd'])
>>> a
a    1.0
b    1.0
c    1.0
d    NaN
dtype: float64
>>> b = pd.Series([1, np.nan, 1, np.nan], index=['a', 'b', 'd', 'e'])
>>> b
a    1.0
b    NaN
d    1.0
e    NaN
dtype: float64
>>> a.subtract(b, fill_value=0)
a    0.0
b    1.0
c    1.0
d   -1.0
e    NaN
dtype: float64


pandas.Series.subtract   Series.subtract(other, level=None, fill_value=None, axis=0)[source]

Return Subtraction of series and other, element-wise (binary operator sub). Equivalent to series - other, but with support to substitute a fill_value for missing data in either one of the inputs.  Parameters

other:Series or scalar value

fill_value:None or float value, default None (NaN)

Fill existing missing (NaN) values, and any new element needed for successful Series alignment, with this value before computation. If data in both corresponding Series locations is missing the result of filling (at that location) will be missing.
level:int or name

Broadcast across a level, matching Index values on the passed MultiIndex level.    Returns
 Series

The result of the operation.      See also  Series.rsub

Reverse of the Subtraction operator, see Python documentation for more details.    Examples
>>> a = pd.Series([1, 1, 1, np.nan], index=['a', 'b', 'c', 'd'])
>>> a
a    1.0
b    1.0
c    1.0
d    NaN
dtype: float64
>>> b = pd.Series([1, np.nan, 1, np.nan], index=['a', 'b', 'd', 'e'])
>>> b
a    1.0
b    NaN
d    1.0
e    NaN
dtype: float64
>>> a.subtract(b, fill_value=0)
a    0.0
b    1.0
c    1.0
d   -1.0
e    NaN
dtype: float64


pandas.Series.sum   Series.sum(axis=None, skipna=True, level=None, numeric_only=None, min_count=0, **kwargs)[source]

Return the sum of the values over the requested axis. This is equivalent to the method numpy.sum.  Parameters

axis:{index (0)}

Axis for the function to be applied on.
skipna:bool, default True

Exclude NA/null values when computing the result.
level:int or level name, default None

If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a scalar.
numeric_only:bool, default None

Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data. Not implemented for Series.
min_count:int, default 0

The required number of valid values to perform the operation. If fewer than min_count non-NA values are present the result will be NA.  **kwargs

Additional keyword arguments to be passed to the function.    Returns
 scalar or Series (if level specified)
    See also  Series.sum

Return the sum.  Series.min

Return the minimum.  Series.max

Return the maximum.  Series.idxmin

Return the index of the minimum.  Series.idxmax

Return the index of the maximum.  DataFrame.sum

Return the sum over the requested axis.  DataFrame.min

Return the minimum over the requested axis.  DataFrame.max

Return the maximum over the requested axis.  DataFrame.idxmin

Return the index of the minimum over the requested axis.  DataFrame.idxmax

Return the index of the maximum over the requested axis.    Examples
>>> idx = pd.MultiIndex.from_arrays([
...     ['warm', 'warm', 'cold', 'cold'],
...     ['dog', 'falcon', 'fish', 'spider']],
...     names=['blooded', 'animal'])
>>> s = pd.Series([4, 2, 0, 8], name='legs', index=idx)
>>> s
blooded  animal
warm     dog       4
         falcon    2
cold     fish      0
         spider    8
Name: legs, dtype: int64

>>> s.sum()
14
  By default, the sum of an empty or all-NA Series is 0.
>>> pd.Series([], dtype="float64").sum()  # min_count=0 is the default
0.0
  This can be controlled with the min_count parameter. For example, if you’d like the sum of an empty series to be NaN, pass min_count=1.
>>> pd.Series([], dtype="float64").sum(min_count=1)
nan
  Thanks to the skipna parameter, min_count handles all-NA and empty series identically.
>>> pd.Series([np.nan]).sum()
0.0

>>> pd.Series([np.nan]).sum(min_count=1)
nan


pandas.Series.swapaxes   Series.swapaxes(axis1, axis2, copy=True)[source]

Interchange axes and swap values axes appropriately.  Returns

y:same as input


pandas.Series.swaplevel   Series.swaplevel(i=- 2, j=- 1, copy=True)[source]

Swap levels i and j in a MultiIndex. Default is to swap the two innermost levels of the index.  Parameters

i, j:int or str

Levels of the indices to be swapped. Can pass level name as string.
copy:bool, default True

Whether to copy underlying data.    Returns
 Series

Series with levels swapped in MultiIndex.     Examples
>>> s = pd.Series(
...     ["A", "B", "A", "C"],
...     index=[
...         ["Final exam", "Final exam", "Coursework", "Coursework"],
...         ["History", "Geography", "History", "Geography"],
...         ["January", "February", "March", "April"],
...     ],
... )
>>> s
Final exam  History     January      A
            Geography   February     B
Coursework  History     March        A
            Geography   April        C
dtype: object
  In the following example, we will swap the levels of the indices. Here, we will swap the levels column-wise, but levels can be swapped row-wise in a similar manner. Note that column-wise is the default behaviour. By not supplying any arguments for i and j, we swap the last and second to last indices.
>>> s.swaplevel()
Final exam  January     History         A
            February    Geography       B
Coursework  March       History         A
            April       Geography       C
dtype: object
  By supplying one argument, we can choose which index to swap the last index with. We can for example swap the first index with the last one as follows.
>>> s.swaplevel(0)
January     History     Final exam      A
February    Geography   Final exam      B
March       History     Coursework      A
April       Geography   Coursework      C
dtype: object
  We can also define explicitly which indices we want to swap by supplying values for both i and j. Here, we for example swap the first and second indices.
>>> s.swaplevel(0, 1)
History     Final exam  January         A
Geography   Final exam  February        B
History     Coursework  March           A
Geography   Coursework  April           C
dtype: object


pandas.Series.T   propertySeries.T

Return the transpose, which is by definition self.


pandas.Series.tail   Series.tail(n=5)[source]

Return the last n rows. This function returns last n rows from the object based on position. It is useful for quickly verifying data, for example, after sorting or appending rows. For negative values of n, this function returns all rows except the first n rows, equivalent to df[n:].  Parameters

n:int, default 5

Number of rows to select.    Returns
 type of caller

The last n rows of the caller object.      See also  DataFrame.head

The first n rows of the caller object.    Examples
>>> df = pd.DataFrame({'animal': ['alligator', 'bee', 'falcon', 'lion',
...                    'monkey', 'parrot', 'shark', 'whale', 'zebra']})
>>> df
      animal
0  alligator
1        bee
2     falcon
3       lion
4     monkey
5     parrot
6      shark
7      whale
8      zebra
  Viewing the last 5 lines
>>> df.tail()
   animal
4  monkey
5  parrot
6   shark
7   whale
8   zebra
  Viewing the last n lines (three in this case)
>>> df.tail(3)
  animal
6  shark
7  whale
8  zebra
  For negative values of n
>>> df.tail(-3)
   animal
3    lion
4  monkey
5  parrot
6   shark
7   whale
8   zebra


pandas.Series.take   Series.take(indices, axis=0, is_copy=None, **kwargs)[source]

Return the elements in the given positional indices along an axis. This means that we are not indexing according to actual values in the index attribute of the object. We are indexing according to the actual position of the element in the object.  Parameters

indices:array-like

An array of ints indicating which positions to take.
axis:{0 or ‘index’, 1 or ‘columns’, None}, default 0

The axis on which to select elements. 0 means that we are selecting rows, 1 means that we are selecting columns.
is_copy:bool

Before pandas 1.0, is_copy=False can be specified to ensure that the return value is an actual copy. Starting with pandas 1.0, take always returns a copy, and the keyword is therefore deprecated.  Deprecated since version 1.0.0.   **kwargs

For compatibility with numpy.take(). Has no effect on the output.    Returns

taken:same type as caller

An array-like containing the elements taken from the object.      See also  DataFrame.loc

Select a subset of a DataFrame by labels.  DataFrame.iloc

Select a subset of a DataFrame by positions.  numpy.take

Take elements from an array along an axis.    Examples
>>> df = pd.DataFrame([('falcon', 'bird', 389.0),
...                    ('parrot', 'bird', 24.0),
...                    ('lion', 'mammal', 80.5),
...                    ('monkey', 'mammal', np.nan)],
...                   columns=['name', 'class', 'max_speed'],
...                   index=[0, 2, 3, 1])
>>> df
     name   class  max_speed
0  falcon    bird      389.0
2  parrot    bird       24.0
3    lion  mammal       80.5
1  monkey  mammal        NaN
  Take elements at positions 0 and 3 along the axis 0 (default). Note how the actual indices selected (0 and 1) do not correspond to our selected indices 0 and 3. That’s because we are selecting the 0th and 3rd rows, not rows whose indices equal 0 and 3.
>>> df.take([0, 3])
     name   class  max_speed
0  falcon    bird      389.0
1  monkey  mammal        NaN
  Take elements at indices 1 and 2 along the axis 1 (column selection).
>>> df.take([1, 2], axis=1)
    class  max_speed
0    bird      389.0
2    bird       24.0
3  mammal       80.5
1  mammal        NaN
  We may take elements using negative integers for positive indices, starting from the end of the object, just like with Python lists.
>>> df.take([-1, -2])
     name   class  max_speed
1  monkey  mammal        NaN
3    lion  mammal       80.5


pandas.Series.to_clipboard   Series.to_clipboard(excel=True, sep=None, **kwargs)[source]

Copy object to the system clipboard. Write a text representation of object to the system clipboard. This can be pasted into Excel, for example.  Parameters

excel:bool, default True

Produce output in a csv format for easy pasting into excel.  True, use the provided separator for csv pasting. False, write a string representation of the object to the clipboard.
sep:str, default '\t'

Field delimiter.  **kwargs

These parameters will be passed to DataFrame.to_csv.      See also  DataFrame.to_csv

Write a DataFrame to a comma-separated values (csv) file.  read_clipboard

Read text from clipboard and pass to read_csv.    Notes Requirements for your platform.
 Linux : xclip, or xsel (with PyQt4 modules) Windows : none macOS : none
 Examples Copy the contents of a DataFrame to the clipboard.
>>> df = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=['A', 'B', 'C'])

>>> df.to_clipboard(sep=',')
... # Wrote the following to the system clipboard:
... # ,A,B,C
... # 0,1,2,3
... # 1,4,5,6
  We can omit the index by passing the keyword index and setting it to false.
>>> df.to_clipboard(sep=',', index=False)
... # Wrote the following to the system clipboard:
... # A,B,C
... # 1,2,3
... # 4,5,6


pandas.Series.to_csv   Series.to_csv(path_or_buf=None, sep=',', na_rep='', float_format=None, columns=None, header=True, index=True, index_label=None, mode='w', encoding=None, compression='infer', quoting=None, quotechar='"', line_terminator=None, chunksize=None, date_format=None, doublequote=True, escapechar=None, decimal='.', errors='strict', storage_options=None)[source]

Write object to a comma-separated values (csv) file.  Parameters

path_or_buf:str, path object, file-like object, or None, default None

String, path object (implementing os.PathLike[str]), or file-like object implementing a write() function. If None, the result is returned as a string. If a non-binary file object is passed, it should be opened with newline=’’, disabling universal newlines. If a binary file object is passed, mode might need to contain a ‘b’.  Changed in version 1.2.0: Support for binary file objects was introduced.
sep:str, default ‘,’

String of length 1. Field delimiter for the output file.
na_rep:str, default ‘’

Missing data representation.
float_format:str, default None

Format string for floating point numbers.
columns:sequence, optional

Columns to write.
header:bool or list of str, default True

Write out the column names. If a list of strings is given it is assumed to be aliases for the column names.
index:bool, default True

Write row names (index).
index_label:str or sequence, or False, default None

Column label for index column(s) if desired. If None is given, and header and index are True, then the index names are used. A sequence should be given if the object uses MultiIndex. If False do not print fields for index names. Use index_label=False for easier importing in R.
mode:str

Python write mode, default ‘w’.
encoding:str, optional

A string representing the encoding to use in the output file, defaults to ‘utf-8’. encoding is not supported if path_or_buf is a non-binary file object.
compression:str or dict, default ‘infer’

For on-the-fly compression of the output data. If ‘infer’ and ‘%s’ path-like, then detect compression from the following extensions: ‘.gz’, ‘.bz2’, ‘.zip’, ‘.xz’, or ‘.zst’ (otherwise no compression). Set to None for no compression. Can also be a dict with key 'method' set to one of {'zip', 'gzip', 'bz2', 'zstd'} and other key-value pairs are forwarded to zipfile.ZipFile, gzip.GzipFile, bz2.BZ2File, or zstandard.ZstdDecompressor, respectively. As an example, the following could be passed for faster compression and to create a reproducible gzip archive: compression={'method': 'gzip', 'compresslevel': 1, 'mtime': 1}.  Changed in version 1.0.0: May now be a dict with key ‘method’ as compression mode and other entries as additional compression options if compression mode is ‘zip’.   Changed in version 1.1.0: Passing compression options as keys in dict is supported for compression modes ‘gzip’, ‘bz2’, ‘zstd’, and ‘zip’.   Changed in version 1.2.0: Compression is supported for binary file objects.   Changed in version 1.2.0: Previous versions forwarded dict entries for ‘gzip’ to gzip.open instead of gzip.GzipFile which prevented setting mtime.
quoting:optional constant from csv module

Defaults to csv.QUOTE_MINIMAL. If you have set a float_format then floats are converted to strings and thus csv.QUOTE_NONNUMERIC will treat them as non-numeric.
quotechar:str, default ‘"’

String of length 1. Character used to quote fields.
line_terminator:str, optional

The newline character or character sequence to use in the output file. Defaults to os.linesep, which depends on the OS in which this method is called (’\n’ for linux, ‘\r\n’ for Windows, i.e.).
chunksize:int or None

Rows to write at a time.
date_format:str, default None

Format string for datetime objects.
doublequote:bool, default True

Control quoting of quotechar inside a field.
escapechar:str, default None

String of length 1. Character used to escape sep and quotechar when appropriate.
decimal:str, default ‘.’

Character recognized as decimal separator. E.g. use ‘,’ for European data.
errors:str, default ‘strict’

Specifies how encoding and decoding errors are to be handled. See the errors argument for open() for a full list of options.  New in version 1.1.0.
storage_options:dict, optional

Extra options that make sense for a particular storage connection, e.g. host, port, username, password, etc. For HTTP(S) URLs the key-value pairs are forwarded to urllib as header options. For other URLs (e.g. starting with “s3://”, and “gcs://”) the key-value pairs are forwarded to fsspec. Please see fsspec and urllib for more details.  New in version 1.2.0.     Returns
 None or str

If path_or_buf is None, returns the resulting csv format as a string. Otherwise returns None.      See also  read_csv

Load a CSV file into a DataFrame.  to_excel

Write DataFrame to an Excel file.    Examples
>>> df = pd.DataFrame({'name': ['Raphael', 'Donatello'],
...                    'mask': ['red', 'purple'],
...                    'weapon': ['sai', 'bo staff']})
>>> df.to_csv(index=False)
'name,mask,weapon\nRaphael,red,sai\nDonatello,purple,bo staff\n'
  Create ‘out.zip’ containing ‘out.csv’
>>> compression_opts = dict(method='zip',
...                         archive_name='out.csv')
>>> df.to_csv('out.zip', index=False,
...           compression=compression_opts)
  To write a csv file to a new folder or nested folder you will first need to create it using either Pathlib or os:
>>> from pathlib import Path
>>> filepath = Path('folder/subfolder/out.csv')
>>> filepath.parent.mkdir(parents=True, exist_ok=True)
>>> df.to_csv(filepath)

>>> import os
>>> os.makedirs('folder/subfolder', exist_ok=True)
>>> df.to_csv('folder/subfolder/out.csv')


pandas.Series.to_dict   Series.to_dict(into=<class 'dict'>)[source]

Convert Series to {label -> value} dict or dict-like object.  Parameters

into:class, default dict

The collections.abc.Mapping subclass to use as the return object. Can be the actual class or an empty instance of the mapping type you want. If you want a collections.defaultdict, you must pass it initialized.    Returns
 collections.abc.Mapping

Key-value representation of Series.     Examples
>>> s = pd.Series([1, 2, 3, 4])
>>> s.to_dict()
{0: 1, 1: 2, 2: 3, 3: 4}
>>> from collections import OrderedDict, defaultdict
>>> s.to_dict(OrderedDict)
OrderedDict([(0, 1), (1, 2), (2, 3), (3, 4)])
>>> dd = defaultdict(list)
>>> s.to_dict(dd)
defaultdict(<class 'list'>, {0: 1, 1: 2, 2: 3, 3: 4})