Skip to main content

unary_operations

Unary (one reference argument) transformations.

This module contains the base class and concrete classes for unary transformations, those that take a single reference argument (i.e. a column or transformation name).

Classes

InclusionTransformation

class InclusionTransformation(    *, name: Optional[str] = None, output: bool = False, arg: str, in_str: str,):

Represents the test for substring inclusion in a column's entries.

Check whether in_str (the test string) is in the elements of arg (the column).

Arguments

  • in_str: The string to test for inclusion.

Method generated by attrs for class InclusionTransformation.

Variables

  • static in_str : str

OneHotEncodingTransformation

class OneHotEncodingTransformation(    *,    name: Optional[str] = None,    output: bool = False,    arg: str,    unknown_suffix: str = 'UNKNOWN',    raw_values: Union[List[Any], Dict[Any, Optional[str]]],):

One hot encoding transformation.

Represents the transformation of a column into a series of one-hot encoded columns.

Attributes

  • arg: Column or transformation reference to one-hot encode.

  • values: Column values that should be one-hot encoded. This can either be a list of values, in which case the one-hot encoding will produce columns named {name}_{value}, or a dictionary of values to desired column suffixes, in which case the encoding will use those suffixes (if an entry in the dictionary maps to None, the column name will be generated in the same way as described above).

      If `name` is not set, the column or transformation reference from
    `arg` will be used instead.

    Any value found in the column which is not enumerated in this argument
    will be encoded in an `{name}_{unknown_suffix}` column. This column is
    therefore protected and any value or value-column mapping that could
    clash will raise ValueError. If you need to encode such a value,
    `unknown_suffix` must be changed
  • unknown_suffix: The suffix to use to create a column for encoding unknown values. The column will be created as {name}_{unknown_suffix}. Default is "UNKNOWN".

Raises

  • ValueError: If any name in values would cause a clash with the unknown value column created by unknown_suffix or with another generated column.
  • ValueError: If no values were provided.
  • ValueError: If no name is provided and the reference in arg cannot be found.

Method generated by attrs for class OneHotEncodingTransformation.

Variables

  • static unknown_suffix : str
  • static values : Dict[Any, str]
  • columns : List[str] - Lists the columns that will be output.
  • prefix - Uses name as prefix or extract from arg (should be col or transform ref).
  • unknown_col : str - Returns the name of the column that unknown values are encoded to.

StringUnaryOperation

class StringUnaryOperation(*, name: Optional[str] = None, output: bool = False, arg: str):

This class represents any UnaryOperation where arg can only be a string.

Arguments

  • arg: The argument to the transformation as a string.

Method generated by attrs for class StringUnaryOperation.

Variables

  • static arg : str

UnaryOperation

class UnaryOperation(*, name: Optional[str] = None, output: bool = False, arg: Any):

The base abstract class for all Unary Operation Transformations.

Arguments

  • arg: The argument to the transformation.

Method generated by attrs for class UnaryOperation.

Variables

  • static arg : Any