Skip to main content
Version: 1.9.1

Expr.str.to_integer

def to_integer(base: int | td_IntoExprColumn = 10, strict: bool = True) -> Expr

Categories: type_casting

Covert a string to integer.

Parameters

parameter
base

The base of the integer.

parameter
strict

If 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 │
╞══════╪════════════╡
11
2.2 ┆ null │
│ a ┆ null │
│ null ┆ null │
└──────┴────────────┘