Skip to main content
Pixeltable UDFs for StringType. It closely follows the Pandas pandas.Series.str API. Example:
import pixeltable as pxt

t = pxt.get_table(...)
t.select(t.str_col.capitalize()).collect()
View source on GitHub

UDFs


capitalize() udf

Return string with its first character capitalized and the rest lowercased. Equivalent to str.capitalize(). Signature:
capitalize(self: String)-> String

casefold() udf

Return a casefolded copy of string. Equivalent to str.casefold(). Signature:
casefold(self: String)-> String

center() udf

Return a centered string of length width. Equivalent to str.center(). Signature:
center(
    self: String,
    width: Int,
    fillchar: String
)-> String
Parameters:
  • width (Int): Total width of the resulting string.
  • fillchar (String): Character used for padding.

contains() udf

Test if string contains a substring. Signature:
contains(
    self: String,
    substr: String,
    case: Bool
)-> Bool
Parameters:
  • substr (String): string literal or regular expression
  • case (Bool): if False, ignore case

contains_re() udf

Test if string contains a regular expression pattern. Signature:
contains_re(
    self: String,
    pattern: String,
    flags: Int
)-> Bool
Parameters:
  • pattern (String): regular expression pattern
  • flags (Int): flags for the re module

count() udf

Count occurrences of pattern or regex. Signature:
count(
    self: String,
    pattern: String,
    flags: Int
)-> Int
Parameters:
  • pattern (String): string literal or regular expression
  • flags (Int): flags for the re module

endswith() udf

Return True if the string ends with the specified suffix, otherwise return False. Equivalent to str.endswith(). Signature:
endswith(
    self: String,
    substr: String
)-> Bool
Parameters:
  • substr (String): string literal

fill() udf

Wraps the single paragraph in string, and returns a single string containing the wrapped paragraph. Equivalent to textwrap.fill(). Signature:
fill(
    self: String,
    width: Int,
    **kwargs
)-> String
Parameters:
  • width (Int): Maximum line width.
  • kwargs (Any): Additional keyword arguments to pass to textwrap.fill().

find() udf

Return the lowest index in string where substr is found within the slice s[start:end]. Equivalent to str.find(). Signature:
find(
    self: String,
    substr: String,
    start: Int,
    end: Optional[Int]
)-> Int
Parameters:
  • substr (String): substring to search for
  • start (Int): slice start
  • end (Optional[Int]): slice end

findall() udf

Find all occurrences of a regular expression pattern in string. Equivalent to re.findall(). Signature:
findall(
    self: String,
    pattern: String,
    flags: Int
)-> Json
Parameters:
  • pattern (String): regular expression pattern
  • flags (Int): flags for the re module

format() udf

Perform string formatting. Equivalent to str.format(). Signature:
format(
    self: String,
    *args,
    **kwargs
)-> String

fullmatch() udf

Determine if string fully matches a regular expression. Equivalent to re.fullmatch(). Signature:
fullmatch(
    self: String,
    pattern: String,
    case: Bool,
    flags: Int
)-> Bool
Parameters:
  • pattern (String): regular expression pattern
  • case (Bool): if False, ignore case
  • flags (Int): flags for the re module

index() udf

Return the lowest index in string where substr is found within the slice [start:end]. Raises ValueError if substr is not found. Equivalent to str.index(). Signature:
index(
    self: String,
    substr: String,
    start: Int,
    end: Optional[Int]
)-> Int
Parameters:
  • substr (String): substring to search for
  • start (Int): slice start
  • end (Optional[Int]): slice end

isalnum() udf

Return True if all characters in the string are alphanumeric and there is at least one character, False otherwise. Equivalent to [str.isalnum()](https://docs.python.org/3/library/stdtypes.html#str.isalnum Signature:
isalnum(self: String)-> Bool

isalpha() udf

Return True if all characters in the string are alphabetic and there is at least one character, False otherwise. Equivalent to str.isalpha(). Signature:
isalpha(self: String)-> Bool

isascii() udf

Return True if the string is empty or all characters in the string are ASCII, False otherwise. Equivalent to str.isascii(). Signature:
isascii(self: String)-> Bool

isdecimal() udf

Return True if all characters in the string are decimal characters and there is at least one character, False otherwise. Equivalent to str.isdecimal(). Signature:
isdecimal(self: String)-> Bool

isdigit() udf

Return True if all characters in the string are digits and there is at least one character, False otherwise. Equivalent to str.isdigit(). Signature:
isdigit(self: String)-> Bool

isidentifier() udf

Return True if the string is a valid identifier according to the language definition, False otherwise. Equivalent to str.isidentifier() Signature:
isidentifier(self: String)-> Bool

islower() udf

Return True if all cased characters in the string are lowercase and there is at least one cased character, False otherwise. Equivalent to str.islower() Signature:
islower(self: String)-> Bool

isnumeric() udf

Return True if all characters in the string are numeric characters, False otherwise. Equivalent to str.isnumeric() Signature:
isnumeric(self: String)-> Bool

isspace() udf

Return True if there are only whitespace characters in the string and there is at least one character, False otherwise. Equivalent to str.isspace() Signature:
isspace(self: String)-> Bool

istitle() udf

Return True if the string is a titlecased string and there is at least one character, False otherwise. Equivalent to str.istitle() Signature:
istitle(self: String)-> Bool

isupper() udf

Return True if all cased characters in the string are uppercase and there is at least one cased character, False otherwise. Equivalent to str.isupper() Signature:
isupper(self: String)-> Bool

join() udf

Return a string which is the concatenation of the strings in elements. Equivalent to str.join() Signature:
join(
    sep: String,
    elements: Json
)-> String

len() udf

Return the number of characters in the string. Equivalent to len(str) Signature:
len(self: String)-> Int

ljust() udf

Return the string left-justified in a string of length width. Equivalent to str.ljust() Signature:
ljust(
    self: String,
    width: Int,
    fillchar: String
)-> String
Parameters:
  • width (Int): Minimum width of resulting string; additional characters will be filled with character defined in fillchar.
  • fillchar (String): Additional character for filling.

lower() udf

Return a copy of the string with all the cased characters converted to lowercase. Equivalent to str.lower() Signature:
lower(self: String)-> String

lstrip() udf

Return a copy of the string with leading characters removed. The chars argument is a string specifying the set of characters to be removed. If omitted or None, whitespace characters are removed. Equivalent to str.lstrip() Signature:
lstrip(
    self: String,
    chars: Optional[String]
)-> String
Parameters:
  • chars (Optional[String]): The set of characters to be removed.

match() udf

Determine if string starts with a match of a regular expression Signature:
match(
    self: String,
    pattern: String,
    case: Bool,
    flags: Int
)-> Bool
Parameters:
  • pattern (String): regular expression pattern
  • case (Bool): if False, ignore case
  • flags (Int): flags for the re module

normalize() udf

Return the Unicode normal form. Equivalent to unicodedata.normalize() Signature:
normalize(
    self: String,
    form: String
)-> String
Parameters:
  • form (String): Unicode normal form ('NFC', 'NFKC', 'NFD', 'NFKD')

pad() udf

Pad string up to width Signature:
pad(
    self: String,
    width: Int,
    side: String,
    fillchar: String
)-> String
Parameters:
  • width (Int): Minimum width of resulting string; additional characters will be filled with character defined in fillchar.
  • side (String): Side from which to fill resulting string ('left', 'right', 'both')
  • fillchar (String): Additional character for filling

partition() udf

Splits 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 string itself, followed by two empty strings. Signature:
partition(
    self: String,
    sep: String
)-> Json

removeprefix() udf

Remove prefix. If the prefix is not present, returns string. Signature:
removeprefix(
    self: String,
    prefix: String
)-> String

removesuffix() udf

Remove suffix. If the suffix is not present, returns string. Signature:
removesuffix(
    self: String,
    suffix: String
)-> String

repeat() udf

Repeat string n times. Signature:
repeat(
    self: String,
    n: Int
)-> String

replace() udf

Replace occurrences of substr with repl. Equivalent to str.replace(). Signature:
replace(
    self: String,
    substr: String,
    repl: String,
    n: Optional[Int]
)-> String
Parameters:
  • substr (String): string literal
  • repl (String): replacement string
  • n (Optional[Int]): number of replacements to make (if None, replace all occurrences)

replace_re() udf

Replace occurrences of a regular expression pattern with repl. Equivalent to re.sub(). Signature:
replace_re(
    self: String,
    pattern: String,
    repl: String,
    n: Optional[Int],
    flags: Int
)-> String
Parameters:
  • pattern (String): regular expression pattern
  • repl (String): replacement string
  • n (Optional[Int]): number of replacements to make (if None, replace all occurrences)
  • flags (Int): flags for the re module

reverse() udf

Return a reversed copy of the string. Equivalent to str[::-1]. Signature:
reverse(self: String)-> String

rfind() udf

Return the highest index where substr is found, such that substr is contained within [start:end]. Equivalent to str.rfind(). Signature:
rfind(
    self: String,
    substr: String,
    start: Optional[Int],
    end: Optional[Int]
)-> Int
Parameters:
  • substr (String): substring to search for
  • start (Optional[Int]): slice start
  • end (Optional[Int]): slice end

rindex() udf

Return the highest index where substr is found, such that substr is contained within [start:end]. Raises ValueError if substr is not found. Equivalent to str.rindex(). Signature:
rindex(
    self: String,
    substr: String,
    start: Optional[Int],
    end: Optional[Int]
)-> Int

rjust() udf

Return the string right-justified in a string of length width. Equivalent to str.rjust(). Signature:
rjust(
    self: String,
    width: Int,
    fillchar: String
)-> String
Parameters:
  • width (Int): Minimum width of resulting string.
  • fillchar (String): Additional character for filling.

rpartition() udf

This method splits string at the last occurrence of sep, and returns a list containing the part before the separator, the separator itself, and the part after the separator. Signature:
rpartition(
    self: String,
    sep: String
)-> Json

rstrip() udf

Return a copy of string with trailing characters removed. Equivalent to str.rstrip(). Signature:
rstrip(
    self: String,
    chars: Optional[String]
)-> String
Parameters:
  • chars (Optional[String]): The set of characters to be removed. If omitted or None, whitespace characters are removed.

slice() udf

Return a slice. Signature:
slice(
    self: String,
    start: Optional[Int],
    stop: Optional[Int],
    step: Optional[Int]
)-> String
Parameters:
  • start (Optional[Int]): slice start
  • stop (Optional[Int]): slice end
  • step (Optional[Int]): slice step

slice_replace() udf

Replace a positional slice with another value. Signature:
slice_replace(
    self: String,
    start: Optional[Int],
    stop: Optional[Int],
    repl: Optional[String]
)-> String
Parameters:
  • start (Optional[Int]): slice start
  • stop (Optional[Int]): slice end
  • repl (Optional[String]): replacement value

startswith() udf

Return True if string starts with substr, otherwise return False. Equivalent to str.startswith(). Signature:
startswith(
    self: String,
    substr: String
)-> Int
Parameters:
  • substr (String): string literal

strip() udf

Return a copy of string with leading and trailing characters removed. Equivalent to str.strip(). Signature:
strip(
    self: String,
    chars: Optional[String]
)-> String
Parameters:
  • chars (Optional[String]): The set of characters to be removed. If omitted or None, whitespace characters are removed.

swapcase() udf

Return a copy of string with uppercase characters converted to lowercase and vice versa. Equivalent to str.swapcase(). Signature:
swapcase(self: String)-> String

title() udf

Return a titlecased version of string, i.e. words start with uppercase characters, all remaining cased characters are lowercase. Equivalent to str.title(). Signature:
title(self: String)-> String

upper() udf

Return a copy of string converted to uppercase. Equivalent to str.upper(). Signature:
upper(self: String)-> String

wrap() udf

Wraps the single paragraph in string so every line is at most width characters long. Returns a list of output lines, without final newlines. Equivalent to textwrap.fill(). Signature:
wrap(
    self: String,
    width: Int,
    **kwargs
)-> Json
Parameters:
  • width (Int): Maximum line width.
  • kwargs (Any): Additional keyword arguments to pass to textwrap.fill().

zfill() udf

Pad a numeric string with ASCII 0 on the left to a total length of width. Equivalent to str.zfill(). Signature:
zfill(
    self: String,
    width: Int
)-> String
Parameters:
  • width (Int): Minimum width of resulting string.
I