Cast: Change the data type of a field

class txf.Cast(source, input, result_type)

The Cast transform casts the values in a field to a Python type. Cast is a special case of Format.

source: Transform

The input pipeline.

input: str

The name of the field to cast. The contents will be replaced, so use Copy to preserve the original.

result_type: type

A Python type object to perform the cast.

Usage

Cast(p, 'Year', int)
Cast(p, 'Timestamp', datetime.datetime)

Example

Query

Mode

Run

Branch

01

PARALLEL

master

01

PARALLEL

Cold run…DONE

master

01

PARALLEL

1/5…0.083052

master

01

PARALLEL

2/5…0.079075

master

01

PARALLEL

3/5…0.079176

master

01

PARALLEL

4/5…0.078928

master

01

PARALLEL

5/5…0.079142

master

Cast(p, 'Query', int)

Query

Mode

Run

Branch

1

PARALLEL

master

1

PARALLEL

Cold run…DONE

master

1

PARALLEL

1/5…0.083052

master

1

PARALLEL

2/5…0.079075

master

1

PARALLEL

3/5…0.079176

master

1

PARALLEL

4/5…0.078928

master

1

PARALLEL

5/5…0.079142

master