string_split
laktory.polars.expressions.string_split
ยค
string_split(x, pattern, key)
Get substring using separator pat
.
PARAMETER | DESCRIPTION |
---|---|
x
|
Input text series to split
TYPE:
|
pattern
|
String or regular expression to split on. If not specified, split on whitespace.
TYPE:
|
key
|
Split index to return
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Expr
|
Result |
Examples:
import laktory # noqa: F401
import polars as pl
df = pl.DataFrame({"x": ["price_close"]})
df = df.with_columns(
y=pl.Expr.laktory.string_split(pl.col("x"), pattern="_", key=1)
)
print(df.glimpse(return_as_string=True))
'''
Rows: 1
Columns: 2
$ x <str> 'price_close'
$ y <str> 'close'
'''
Source code in laktory/polars/expressions/string.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
|