ExprStringNameSpace.json_extract
Similar polars.Expr.str.json_extract, however you can only extract one field! You must specify the field. If the field is not in the json, the value will be null.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field |
str
|
The field to extract from the json |
required |
Examples:
>>> qc = QuokkaContext()
>>> a = polars.from_dict({"a":[1,1,2,2], "c": ["A","B","C","D"], "b":['{"my_field": "quack"}','{"my_field": "quack"}','{"my_field": "quack"}','{"my_field": "quack"}']})
>>> a = qc.from_polars(a)
>>> a.with_columns({"my_field": a["b"].str.json_extract("my_field")}).collect()
Source code in pyquokka/expression.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
|