Series.Str (SeriesStrNameSpace)
Namespace: Polars.FSharp
Instance Methods
Contains
Checks if the string contains the given pattern.
member Contains(pattern: string, ?literal: bool, ?strict: bool) : SeriesParameters
| Name | Type | Description |
|---|---|---|
pattern | string | The pattern to search for. Can be a literal string or a regex pattern. |
literal | bool (optional) | If true, treat the pattern as a literal string (not a regex). |
strict | bool (optional) | If true, throw an error if the pattern is not found. |
Returns: An expression that returns a boolean indicating whether the pattern was found.
ContainsAny
Checks if the strings contain any of the given patterns.
member ContainsAny(pattern: string, ?asciiCaseInsensitive: bool) : SeriesParameters
| Name | Type | Description |
|---|---|---|
pattern | string | The pattern to search for. This is treated as a regex pattern. |
asciiCaseInsensitive | bool (optional) | If true, perform case-insensitive matching for ASCII characters. |
Returns: An expression that returns a boolean indicating whether any of the patterns were found.
CountMatches
Counts the number of non-overlapping matches of the pattern in the string.
member CountMatches(pattern: string, ?literal: bool) : SeriesParameters
| Name | Type | Description |
|---|---|---|
pattern | string | The pattern to search for. Can be a literal string or a regex pattern. |
literal | bool (optional) | If true, treat the pattern as a literal string (not a regex). |
Returns: An expression that returns the count of matches.
Decode
Decode a Bytes Series into a String Series, using the specified encoding.
member Decode(encoding: TransferEncoding, ?strict: bool) : SeriesParameters
| Name | Type | Description |
|---|---|---|
encoding | TransferEncoding | The Charset encoding to use for the conversion. |
strict | bool (optional) | If true, invalid bytes will raise an exception. If false, they will be replaced with the replacement character. |
Returns: An expression that converts the Bytes Series to a String Series.
Encode
Encode a String Series into a Bytes Series, using the specified encoding.
member Encode(encoding: TransferEncoding) : SeriesParameters
| Name | Type | Description |
|---|---|---|
encoding | TransferEncoding | The Charset encoding to use for the conversion. |
Returns: An expression that converts the String Series to a Bytes Series.
EndsWith
Check if the string ends with the given suffix.
member EndsWith(suffix: string) : SeriesParameters
| Name | Type | Description |
|---|---|---|
suffix | string | The suffix to check for. |
Returns: An expression that returns true if the string ends with the suffix, false otherwise.
EscapeRegex
Returns string values with all regular expression meta characters escaped.
member EscapeRegex : unit -> SeriesExtract
Extract the target capture group from a regex pattern.
member Extract(pattern: string, ?groupIndex: int) : SeriesParameters
| Name | Type | Description |
|---|---|---|
pattern | string | Regex pattern with capture groups. |
groupIndex | int (optional) | The index of the capture group to extract (default is 1). |
ExtractGroups
Extracts all matches for the given regex pattern.
member ExtractGroups(pattern: string) : SeriesParameters
| Name | Type | Description |
|---|---|---|
pattern | string | A valid regular expression pattern, compatible with the regex crate. |
Returns: An expression that, for each row, returns a list of all non-overlapping matches of the given regex pattern. If no match is found, an empty list is returned. If a row contains null, null is returned.
ExtractMany
Extracts all successive non-overlapping regex matches in an individual string as a list.
member ExtractMany(
patterns: Expr,
?asciiCaseInsensitive: bool,
?overlapping: bool,
?leftmost: bool
) : SeriesParameters
| Name | Type | Description |
|---|---|---|
patterns | Expr | String patterns to search. This method supports matching on string literals only, and does not support regular expression matching. |
asciiCaseInsensitive | bool (optional) | Enable ASCII-aware case-insensitive matching. |
overlapping | bool (optional) | Whether matches may overlap. |
leftmost | bool (optional) | Guarantees in case there are overlapping matches that the leftmost match is used. |
Find
Return the bytes offset of the first substring matching a pattern. If the pattern is not found, returns None.
member Find(pattern: string, ?literal: bool, ?strict: bool) : SeriesParameters
| Name | Type | Description |
|---|---|---|
pattern | string | A valid regular expression pattern, compatible with the regex crate. |
literal | bool (optional) | Treat pattern as a literal string, not as a regular expression. |
strict | bool (optional) | Raise an error if the underlying pattern is not a valid regex, otherwise mask out with a null value. |
FindMany
Return the bytes offset of all non-overlapping substrings matching a pattern. If the pattern is not found, an empty list is returned.
member FindMany(
patterns: Expr,
?asciiCaseInsensitive: bool,
?overlapping: bool,
?leftmost: bool
) : SeriesParameters
| Name | Type | Description |
|---|---|---|
patterns | Expr | An expression yielding string patterns to search. This method supports matching on string literals only, and does not support regular expression matching. |
asciiCaseInsensitive | bool (optional) | Enable ASCII-aware case-insensitive matching. When this option is enabled, searching will be performed without respect to case for ASCII letters (a-z and A-Z) only. |
overlapping | bool (optional) | Whether matches may overlap. This is only supported when the search pattern contains a wildcard. |
leftmost | bool (optional) | Guarantees in case there are overlapping matches that the leftmost match is used. In case there are multiple candidates for the leftmost match the pattern which comes first in patterns is used. May not be used together with overlapping = True. |
Head
Return the first n characters of the string.
member Head(n: int) : SeriesParameters
| Name | Type | Description |
|---|---|---|
n | int | The number of characters to return. |
Returns: An expression that returns the first n characters of the string.
Join
Join elements of a string series with a separator.
member Join(?delimiter: string, ?ignoreNulls: bool) : SeriesParameters
| Name | Type | Description |
|---|---|---|
delimiter | string (optional) | The separator to use. Defaults to an empty string. |
ignoreNulls | bool (optional) | Whether to ignore null values. Defaults to true. |
Returns: An expression that joins the elements of the string series.
JsonDecode
Decode a String Series with JSON data into a structured Polars Series (e.g. List, Dict).
member JsonDecode(dtype: DataType) : SeriesParameters
| Name | Type | Description |
|---|---|---|
dtype | DataType | The target DataType to decode the JSON into. This must be a structured type (e.g. DataType.List, DataType.Dict) as JSON decoding is not supported for primitive types like DataType.String or DataType.Int64. |
Returns: A new Series with the decoded JSON data.
JsonPathMatch
Extracts all matches for the given JSONPath expression.
member JsonPathMatch(jsonPath: string) : SeriesParameters
| Name | Type | Description |
|---|---|---|
jsonPath | string | The JSONPath expression to use for extraction. |
Returns: An expression that returns a list of all matches for the given JSONPath expression.
LenBytes
Get length in bytes.
member LenBytes : unit -> SeriesLenChars
Return the length of each string as the number of characters.
member LenChars : unit -> SeriesNormalize
Returns the Unicode normal form of the string values.
member Normalize(form: NormalizationForm) : SeriesParameters
| Name | Type | Description |
|---|---|---|
form | NormalizationForm | Unicode form to use. |
PadEnd
Pad strings to a certain length by adding characters to the end.
member PadEnd(length: int, ?fillChar: string) : SeriesParameters
| Name | Type | Description |
|---|---|---|
length | int | The target length of the strings. |
fillChar | string (optional) | The character to pad with. Defaults to '0'. |
Returns: An expression that pads the strings with trailing characters.
PadStart
Pad strings to a certain length by adding characters to the start.
member PadStart(length: int, ?fillChar: string) : SeriesParameters
| Name | Type | Description |
|---|---|---|
length | int | The target length of the strings. |
fillChar | string (optional) | The character to pad with. Defaults to '0'. |
Returns: An expression that pads the strings with leading characters.
Replace
Replace the first occurrence of a substring or regex pattern with a new value.
member Replace(
pattern: string,
value: string,
?literal: bool,
?n: int
) : SeriesParameters
| Name | Type | Description |
|---|---|---|
pattern | string | Pattern to search for. Can be a literal string or a regex pattern. |
value | string | String to replace the pattern with. |
literal | bool (optional) | If true, treat pattern as a literal string (not a regex). |
n | int (optional) | Maximum number of replacements (default is 1). |
ReplaceAll
Replace all occurrences of a pattern with a new value.
member ReplaceAll(pattern: string, value: string, ?literal: bool) : SeriesParameters
| Name | Type | Description |
|---|---|---|
pattern | string | Pattern to search for. Can be a literal string or a regex pattern. |
value | string | String to replace the pattern with. |
literal | bool (optional) | If true, treat pattern as a literal string (not a regex). |
ReplaceMany
Replace multiple patterns with different replacement values.
member ReplaceMany(
patterns: Expr,
replaceWith: Expr,
?asciiCaseInsensitive: bool,
?leftmost: bool
) : SeriesParameters
| Name | Type | Description |
|---|---|---|
patterns | Expr | Expression yielding string patterns to search and replace. |
replaceWith | Expr | Strings to replace where a pattern was a match. Length must match the length of patterns or have length 1. This can be broadcasted, so it supports many:one and many:many. |
asciiCaseInsensitive | bool (optional) | Enable ASCII-aware case-insensitive matching. |
leftmost | bool (optional) | Guarantees in case there are overlapping matches that the leftmost match is used. |
Reverse
Reverses the order of the characters in each string.
member Reverse : unit -> SeriesSlice
Returns an expression that slices the string by an offset and a length.
member Slice(offset: int64, ?length: uint64) : SeriesParameters
| Name | Type | Description |
|---|---|---|
offset | int64 | Start index. |
length | uint64 (optional) | Length of the slice. |
Split
Splits the string by separator and returns a List column.
member Split(
separator: string,
?inclusive: bool,
?literal: bool,
?strict: bool
) : SeriesParameters
| Name | Type | Description |
|---|---|---|
separator | string | The separator to split by. |
inclusive | bool (optional) | If true, include the separator in the result. |
literal | bool (optional) | If true, treat the separator as a literal string (not a regex). |
strict | bool (optional) | If true, throw an error if the separator is not found. |
Returns: An expression that returns a List column of strings.
SplitExact
Split the string by a separator into a fixed number of pieces.
member SplitExact(separator: string, n: int, ?inclusive: bool) : SeriesParameters
| Name | Type | Description |
|---|---|---|
separator | string | The separator to split by. |
n | int | The number of pieces to split into. |
inclusive | bool (optional) | If true, include the separator in the resulting pieces. |
Returns: An expression that splits the string by the separator into a fixed number of pieces.
SplitN
Split the string by a separator.
member SplitN(separator: string, n: int) : SeriesParameters
| Name | Type | Description |
|---|---|---|
separator | string | The separator to split by. |
n | int | The maximum number of splits to perform. |
Returns: An expression that splits the string by the separator.
StartsWith
Check if the string starts with the given prefix.
member StartsWith(prefix: string) : SeriesParameters
| Name | Type | Description |
|---|---|---|
prefix | string | The prefix to check for. |
Returns: An expression that returns true if the string starts with the prefix, false otherwise.
StripChars
Remove leading and trailing characters.
member StripChars(?characters: string) : SeriesParameters
| Name | Type | Description |
|---|---|---|
characters | string (optional) | - |
StripCharsEnd
Remove trailing characters.
member StripCharsEnd(?characters: string) : SeriesParameters
| Name | Type | Description |
|---|---|---|
characters | string (optional) | - |
StripCharsStart
Remove leading characters.
member StripCharsStart(?characters: string) : SeriesParameters
| Name | Type | Description |
|---|---|---|
characters | string (optional) | - |
StripPrefix
Remove the given prefix from the start of the string.
member StripPrefix(prefix: string) : SeriesParameters
| Name | Type | Description |
|---|---|---|
prefix | string | The prefix to remove. |
Returns: An expression that removes the prefix from the string.
StripSuffix
Remove the given suffix from the end of the string.
member StripSuffix(suffix: string) : SeriesParameters
| Name | Type | Description |
|---|---|---|
suffix | string | The suffix to remove. |
Returns: An expression that removes the suffix from the string.
Strptime
Parse string to datetime with given format.
member Strptime(
dtype: DataType,
?format: string,
?strict: bool,
?exact: bool,
?cache: bool,
?ambiguous: Expr
) : SeriesParameters
| Name | Type | Description |
|---|---|---|
dtype | DataType | Data type. |
format | string (optional) | Date format. |
strict | bool (optional) | Return null when parsing fails. |
exact | bool (optional) | Return null when parsing fails. |
cache | bool (optional) | Use cache. |
ambiguous | Expr (optional) | Ambiguous dates. |
Returns: Series of Datetime.
Tail
Return the last n characters of the string.
member Tail(n: int) : SeriesParameters
| Name | Type | Description |
|---|---|---|
n | int | The number of characters to return. |
Returns: An expression that returns the last n characters of the string.
ToDate
Parse string to Date.
member ToDate(
?format: string,
?strict: bool,
?exact: bool,
?cache: bool
) : SeriesParameters
| Name | Type | Description |
|---|---|---|
format | string (optional) | - |
strict | bool (optional) | - |
exact | bool (optional) | - |
cache | bool (optional) | - |
ToDatetime
Parse string to Datetime.
member ToDatetime(
?format: string,
?timeUnit: TimeUnit,
?timeZone: string,
?strict: bool,
?exact: bool,
?cache: bool,
?ambiguous: Expr
) : SeriesParameters
| Name | Type | Description |
|---|---|---|
format | string (optional) | Date format. |
timeUnit | TimeUnit (optional) | Time unit. |
timeZone | string (optional) | Time zone. |
strict | bool (optional) | Return null when parsing fails. |
exact | bool (optional) | Return null when parsing fails. |
cache | bool (optional) | Use cache. |
ambiguous | Expr (optional) | Ambiguous dates. |
Returns: Series of Datetime.
ToDecimal
Convert string column to decimal.
member ToDecimal(scale: int) : SeriesParameters
| Name | Type | Description |
|---|---|---|
scale | int | Scale of the decimal. |
Returns: Series of decimal.
ToInteger
Convert string column to integer.
member ToInteger(?radix: int, ?dtype: DataType, ?strict: bool) : SeriesParameters
| Name | Type | Description |
|---|---|---|
radix | int (optional) | Radix of the integer. |
dtype | DataType (optional) | Data type of the integer. |
strict | bool (optional) | Return null when parsing fails. |
Returns: Series of integer.
ToLowercase
Convert to lowercase.
member ToLowercase : unit -> SeriesToTime
Parse string to Time.
member ToTime(
?format: string,
?strict: bool,
?exact: bool,
?cache: bool
) : SeriesParameters
| Name | Type | Description |
|---|---|---|
format | string (optional) | Date format. |
strict | bool (optional) | Return null when parsing fails. |
exact | bool (optional) | Return null when parsing fails. |
cache | bool (optional) | Use cache. |
Returns: Series of Time.
ToTitlecase
Modify strings to their titlecase equivalent.
This is a form of case transform where the first letter of each word is capitalized, with the rest of the word in lowercase. Non-alphanumeric characters define the word boundaries.
member ToTitlecase : unit -> SeriesToUppercase
Convert to uppercase.
member ToUppercase : unit -> SeriesZfill
Pad strings with leading zeros until they reach the specified length.
member Zfill(length: int) : SeriesParameters
| Name | Type | Description |
|---|---|---|
length | int | The target length of the strings. |
Returns: An expression that pads the strings with leading zeros.