preheat_open.measurements.Mapper

class preheat_open.measurements.Mapper(map=<factory>, convention=<factory>, _components=<factory>, prefix='', suffix='', separator='_')

Bases: object

Applies a mapping to components and renames DataFrame columns accordingly.

Variables:
  • map (dict[Component, str]) – The mapping of components to strings.

  • convention (list[Mapper]) – The list of mappers to use for generating the map.

  • components (list[Component]) – The list of components to map.

__init__(map=<factory>, convention=<factory>, _components=<factory>, prefix='', suffix='', separator='_')

Methods

__init__([map, convention, _components, ...])

check()

check_ambigiousness()

Checks if the map is ambiguous and raises an error if it is.

create_map()

Creates a map of components to strings based on the convention.

default_column_name(component)

Returns the default column name for a component.

generate_convention()

Generates a convention for mapping components.

get_name(component)

Gets the name for a component based on the convention.

rename_dataframe(df)

Renames the columns of a DataFrame based on the map.

Attributes

components

prefix

separator

suffix

map

convention

check_ambigiousness()

Checks if the map is ambiguous and raises an error if it is.

create_map()

Creates a map of components to strings based on the convention.

default_column_name(component)

Returns the default column name for a component.

Parameters:

component (Component) – The component to get the default column name for.

Returns:

The default column name.

Return type:

int

generate_convention()

Generates a convention for mapping components.

get_name(component)

Gets the name for a component based on the convention.

Parameters:

component (Component) – The component to get the name for.

Returns:

The name of the component.

Return type:

str

rename_dataframe(df)

Renames the columns of a DataFrame based on the map.

Parameters:

df (pd.DataFrame) – The DataFrame to rename.

Returns:

The renamed DataFrame.

Return type:

pd.DataFrame