Class StringMethods (0.23.0)

StringMethods(
    data=None,
    index: vendored_pandas_typing.Axes | None = None,
    dtype: typing.Optional[
        bigframes.dtypes.DtypeString | bigframes.dtypes.Dtype
    ] = None,
    name: str | None = None,
    copy: typing.Optional[bool] = None,
    *,
    session: typing.Optional[bigframes.session.Session] = None
)

Vectorized string functions for Series and Index.

NAs stay NA unless handled otherwise by a particular method. Patterned after Python's string methods, with some inspiration from R's stringr package.

Methods

capitalize

capitalize() -> bigframes.series.Series

Convert strings in the Series/Index to be capitalized.

Equivalent to str.capitalize.

Returns
TypeDescription
bigframes.series.SeriesSeries with captitalized strings.

cat

cat(
    others: typing.Union[str, bigframes.series.Series],
    *,
    join: typing.Literal["outer", "left"] = "left"
) -> bigframes.series.Series

Concatenate strings in the Series/Index with given separator.

If others is specified, this function concatenates the Series/Index and elements of others element-wise.

Parameter
NameDescription
join {'left', 'outer'}, default 'left'

Determines the join-style between the calling Series and any Series in others (objects without an index need to match the length of the calling Series). To disable alignment, use .values on any Series/Index/DataFrame in others.

Returns
TypeDescription
bigframes.series.SeriesSeries with concatenated strings.

center

center(width: int, fillchar: str = " ") -> bigframes.series.Series

Pad left and right side of strings in the Series/Index.

Equivalent to str.center.

Parameters
NameDescription
width int

Minimum width of resulting string; additional characters will be filled with character defined in fillchar.

fillchar str, default ' '

Additional character for filling, default is whitespace.

Returns
TypeDescription
bigframes.series.SeriesReturns Series or Index with minimum number of char in object.

contains

contains(
    pat, case: bool = True, flags: int = 0, *, regex: bool = True
) -> bigframes.series.Series

Test if pattern or regex is contained within a string of a Series or Index.

Return boolean Series or Index based on whether a given pattern or regex is contained within a string of a Series or Index.

Parameters
NameDescription
pat str, re.Pattern

Character sequence or regular expression.

case bool, default True

If True, case sensitive.

flags int, default 0

Flags to pass through to the re module, e.g. re.IGNORECASE.

regex bool, default True

If True, assumes the pat is a regular expression. If False, treats the pat as a literal string.

Returns
TypeDescription
bigframes.series.SeriesA Series or Index of boolean values indicating whether the given pattern is contained within the string of each element of the Series or Index.

endswith

endswith(pat: typing.Union[str, tuple[str, ...]]) -> bigframes.series.Series

Test if the end of each string element matches a pattern.

Parameter
NameDescription
pat str, tuple[str, ...]

Character sequence or tuple of strings. Regular expressions are not accepted.

Returns
TypeDescription
bigframes.series.SeriesA Series of booleans indicating whether the given pattern matches the end of each string element.

extract

extract(pat: str, flags: int = 0) -> bigframes.dataframe.DataFrame

Extract capture groups in the regex pat as columns in a DataFrame.

For each subject string in the Series, extract groups from the first match of regular expression pat.

find

find(
    sub: str, start: typing.Optional[int] = None, end: typing.Optional[int] = None
) -> bigframes.series.Series

Return lowest 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.find.

Parameters
NameDescription
start int, default 0

Left edge index.

end None

Right edge index.

Returns
TypeDescription
bigframes.series.SeriesSeries with lowest indexes in each strings.

fullmatch

fullmatch(pat, case=True, flags=0) -> bigframes.series.Series

Determine if each string entirely matches a regular expression.

Parameters
NameDescription
pat str

Character sequence or regular expression.

case bool

If True, case sensitive.

flags int, default 0

Regex module flags, e.g. re.IGNORECASE.

Returns
TypeDescription
bigframes.series.SeriesSeries of boolean values

get

get(i: int) -> bigframes.series.Series

Extract element from each component at specified position or with specified key.

Extract element from lists, tuples, dict, or strings in each element in the Series/Index.

Parameter
NameDescription
i int

Position or key of element to extract.

Returns
TypeDescription
bigframes.series.SeriesSeries

isalnum

isalnum() -> bigframes.series.Series

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
TypeDescription
bigframes.series.SeriesSeries or Index of boolean values with the same length as the original Series/Index.

isalpha

isalpha() -> bigframes.series.Series

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
TypeDescription
bigframes.series.SeriesSeries with the same length as the originalSeries/Index.

isdecimal

isdecimal() -> bigframes.series.Series

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
TypeDescription
bigframes.series.SeriesSeries or Index of boolean values with the same length as the original Series/Index.

isdigit

isdigit() -> bigframes.series.Series

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
TypeDescription
bigframes.series.SeriesSeries with the same length as the originalSeries/Index.

islower

islower() -> bigframes.series.Series

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
TypeDescription
bigframes.series.SeriesSeries or Index of boolean values with the same length as the original Series/Index.

isnumeric

isnumeric() -> bigframes.series.Series

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
TypeDescription
bigframes.series.SeriesSeries or Index of boolean values with the same length as the original Series/Index.

isspace

isspace() -> bigframes.series.Series

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
TypeDescription
bigframes.series.SeriesSeries or Index of boolean values with the same length as the original Series/Index.

isupper

isupper() -> bigframes.series.Series

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
TypeDescription
bigframes.series.SeriesSeries or Index of boolean values with the same length as the original Series/Index.

len

len() -> bigframes.series.Series

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
TypeDescription
bigframes.series.SeriesA Series or Index of integer values indicating the length of each element in the Series or Index.

ljust

ljust(width, fillchar=" ") -> bigframes.series.Series

Pad right side of strings in the Series/Index up to width.

Parameters
NameDescription
width int

Minimum width of resulting string; additional characters will be filled with character defined in fillchar.

fillchar str, default ' '

Additional character for filling, default is whitespace.

Returns
TypeDescription
bigframes.series.SeriesReturns Series or Index with minimum number of char in object.

lower

lower() -> bigframes.series.Series

Convert strings in the Series/Index to lowercase.

Equivalent to str.lower.

Returns
TypeDescription
bigframes.series.SeriesSeries with lowercase.

lstrip

lstrip() -> bigframes.series.Series

Remove leading characters.

Strip whitespaces (including newlines) or a set of specified characters from each string in the Series/Index from left side. Replaces any non-strings in Series with NaNs. Equivalent to str.lstrip.

Returns
TypeDescription
bigframes.series.SeriesSeries without leading characters.

match

match(pat, case=True, flags=0) -> bigframes.series.Series

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

Parameters
NameDescription
pat str

Character sequence or regular expression.

case bool

If True, case sensitive.

flags int, default 0

Regex module flags, e.g. re.IGNORECASE.

Returns
TypeDescription
bigframes.series.SeriesSeries of boolean values

pad

pad(width, side="left", fillchar=" ") -> bigframes.series.Series

Pad strings in the Series/Index up to width.

Parameters
NameDescription
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
TypeDescription
bigframes.series.SeriesReturns Series or Index with minimum number of char in object.

repeat

repeat(repeats: int) -> bigframes.series.Series

Duplicate each string in the Series or Index.

Returns
TypeDescription
bigframes.series.SeriesSeries or Index of repeated string objects specified by input parameter repeats.

replace

replace(
    pat: typing.Union[str, re.Pattern],
    repl: str,
    *,
    case: typing.Optional[bool] = None,
    flags: int = 0,
    regex: bool = False
) -> bigframes.series.Series

Replace each occurrence of pattern/regex in the Series/Index.

Equivalent to str.replace or re.sub, depending on the regex value.

Parameters
NameDescription
pat str, re.Pattern

String can be a character sequence or regular expression.

repl str

Replacement string.

case 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

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

Returns
TypeDescription
bigframes.series.SeriesA copy of the object with all matching occurrences of pat replaced by repl.

reverse

reverse() -> bigframes.series.Series

Reverse strings in the Series.

rjust

rjust(width, fillchar=" ") -> bigframes.series.Series

Pad left side of strings in the Series/Index up to width.

Parameters
NameDescription
width int

Minimum width of resulting string; additional characters will be filled with character defined in fillchar.

fillchar str, default ' '

Additional character for filling, default is whitespace.

Returns
TypeDescription
bigframes.series.SeriesReturns Series or Index with minimum number of char in object.

rstrip

rstrip() -> bigframes.series.Series

Remove trailing characters.

Strip whitespaces (including newlines) or a set of specified characters from each string in the Series/Index from right side. Replaces any non-strings in Series with NaNs. Equivalent to str.rstrip.

Returns
TypeDescription
bigframes.series.SeriesSeries without trailing characters.

slice

slice(
    start: typing.Optional[int] = None, stop: typing.Optional[int] = None
) -> bigframes.series.Series

Slice substrings from each element in the Series or Index.

Parameters
NameDescription
start int, optional

Start position for slice operation.

stop int, optional

Stop position for slice operation.

step int, optional

Step size for slice operation.

startswith

startswith(pat: typing.Union[str, tuple[str, ...]]) -> bigframes.series.Series

Test if the start of each string element matches a pattern.

Parameter
NameDescription
pat str, tuple[str, ...]

Character sequence or tuple of strings. Regular expressions are not accepted.

Returns
TypeDescription
bigframes.series.SeriesA Series of booleans indicating whether the given pattern matches the start of each string element.

strip

strip() -> bigframes.series.Series

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. Replaces any non-strings in Series with NaNs. Equivalent to str.strip.

Returns
TypeDescription
bigframes.series.SeriesSeries or Index without leading and trailing characters.

upper

upper() -> bigframes.series.Series

Convert strings in the Series/Index to uppercase.

Equivalent to str.upper.

Returns
TypeDescription
bigframes.series.SeriesSeries with uppercase strings.

zfill

zfill(width: int) -> bigframes.series.Series

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.

Parameter
NameDescription
width int

Minimum length of resulting string; strings with length less than width be prepended with '0' characters.

Returns
TypeDescription
bigframes.series.SeriesSeries of objects.