Skip to content

ValueMapping(changes, others=Unmatched.ERROR) Source

The new value of each listed value of an Array, used by Array.apply, such as codes replaced by labels.

A missing value stays missing. The new values share one type: integers and decimals give decimals. Numbers given to an Array of numbers take its type, as with the operators, except decimals given to integers, which give FLOAT64. Other new values give their own type, which also holds the kept values with others=Unmatched.KEEP. Only missing new values keep the type of the Array.

Changed in version 0.2.0

Accepts others=Unmatched.KEEP, which keeps the values without ValueChange. Numbers given to an Array of numbers take its type, as with the operators. Only missing new values keep the type of the Array.

Version history (1)

Added in version 0.1.0

Parameters:

Raises:

Examples:

import numdaplot as ndp

sexes = ndp.Array.from_list([2, 1, 2])
sexes.apply(ndp.ValueMapping(changes=[ndp.ValueChange(1, "Homme"), ndp.ValueChange(2, "Femme")]))
# Array(['Femme', 'Homme', 'Femme'], dtype=TEXT)