Decodes a value using the provided encoding
hex | base64
Optional
strict: booleanhow to handle invalid inputs
- true: method will throw error if unable to decode a value
- false: unhandled values will be replaced with `null`
Decodes a value using the provided encoding
Optional
strict?: booleanExtract the target capture group from provided patterns.
Index of the targeted capture group. Group 0 mean the whole pattern, first group begin at index 1 Default to the first capture group
Utf8 array. Contain null if original value is null or regex capture nothing.
> df = pl.DataFrame({
... 'a': [
... 'http://vote.com/ballon_dor?candidate=messi&ref=polars',
... 'http://vote.com/ballon_dor?candidat=jorginho&ref=polars',
... 'http://vote.com/ballon_dor?candidate=ronaldo&ref=polars'
... ]})
> df.select(pl.col('a').str.extract(/candidate=(\w+)/, 1))
shape: (3, 1)
┌─────────┐
│ a │
│ --- │
│ str │
╞═════════╡
│ messi │
├╌╌╌╌╌╌╌╌╌┤
│ null │
├╌╌╌╌╌╌╌╌╌┤
│ ronaldo │
└─────────┘
Parse string values as JSON. Throw errors if encounter invalid JSON strings.
Optional
dtype: DataTypeOptional
inferSchemaLength: numberDF with struct
>>> df = pl.DataFrame( {json: ['{"a":1, "b": true}', null, '{"a":2, "b": false}']} )
>>> df.select(pl.col("json").str.jsonDecode())
shape: (3, 1)
┌─────────────┐
│ json │
│ --- │
│ struct[2] │
╞═════════════╡
│ {1,true} │
│ {null,null} │
│ {2,false} │
└─────────────┘
See Also
----------
jsonPathMatch : Extract the first match of json string with provided JSONPath expression.
Parse string values as JSON. Throw errors if encounter invalid JSON strings.
Optional
dtype: DataTypeOptional
inferSchemaLength: numberDF with struct
>>> df = pl.DataFrame( {json: ['{"a":1, "b": true}', null, '{"a":2, "b": false}']} )
>>> df.select(pl.col("json").str.jsonExtract())
shape: (3, 1)
┌─────────────┐
│ json │
│ --- │
│ struct[2] │
╞═════════════╡
│ {1,true} │
│ {null,null} │
│ {2,false} │
└─────────────┘
See Also
----------
jsonPathMatch : Extract the first match of json string with provided JSONPath expression.
Extract the first match of json string with provided JSONPath expression. Throw errors if encounter invalid json strings. All return value will be casted to Utf8 regardless of the original value.
Utf8 array. Contain null if original value is null or the jsonPath
return nothing.
Parse a Series of dtype Utf8 to a Date/Datetime Series.
Date or Datetime.
Optional
fmt: stringformatting syntax. Read more
Parse a Series of dtype Utf8 to a Date/Datetime Series.
Date or Datetime.
Optional
fmt: stringformatting syntax. Read more
Parse a Series of dtype Utf8 to a Date/Datetime Series.
Date or Datetime.
Calendar date and time type
Optional
timeUnit: any of 'ms' | 'ns' | 'us'
timezone string as defined by Intl.DateTimeFormat America/New_York
for example.
Optional
fmt: stringformatting syntax. Read more
namespace containing expr string functions