Expr.str.to_integer
methodView source ↗
def to_integer(base: int | td_IntoExprColumn = 10, strict: bool = True) -> Expr
Categories: type_casting
Covert a string to integer.
Parameters
parameter
baseThe base of the integer.
parameter
strictIf true, raise an error if the string is not a valid integer.
Examples
>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a")
.str.to_integer(strict=False).alias("to_integer"))
>>>
┌──────┬────────────┐
│ a ┆ to_integer │
│ --- ┆ --- │
│ str ┆ i64 │
╞══════╪════════════╡
│ 1 ┆ 1 │
│ 2.2 ┆ null │
│ a ┆ null │
│ null ┆ null │
└──────┴────────────┘