datatable.stype.__call__()

Cast column col into the new stype.

An stype can be used as a function that converts columns into that specific stype. In the same way as you could write int(3.14) in Python to convert a float value into integer, you can likewise write dt.int32(f.A) to convert column A into stype int32.

Parameters

col
FExpr

A single- or multi- column expression. All columns will be converted into the desired stype.

return
FExpr

Expression that converts its inputs into the current stype.

Examples

from datatable import dt, f df = dt.Frame({'A': ['1', '1', '2', '1', '2'], 'B': [None, '2', '3', '4', '5'], 'C': [1, 2, 1, 1, 2]}) df
ABC
str32str32int32
01NA1
1122
2231
3141
4252

Convert column A from string stype to integer stype:

df[:, dt.int32(f.A)]
A
int32
01
11
22
31
42

Convert multiple columns to different stypes:

df[:, [dt.int32(f.A), dt.str32(f.C)]]
AC
int32str32
011
112
221
311
422

See Also

dt.as_type() – equivalent method of casting a column into

another stype.