Lookup: Replace a value with one from a lookup table

class txf.Lookup(source, outputs, table[, missing=None])

The Lookup transform replaces field values with the corresponding values in a table. The mapped values do not have to be the same type. Lookup is a subclass of Format.

source: Transform

The input pipeline.

input: str

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

table: dict

A Python dictionary whose keys are the values of input.

missing: any

The value to use if the input value is not found in the table. It must have the same type as the table values.

Usage

Lookup(p, 'State', {'CA': 'California'}, 'Unknown')
Lookup(p, 'Month', {'Jan': 1}, 0)