preheat_open.measurements.Mapper
- class preheat_open.measurements.Mapper(map=<factory>, convention=<factory>, _components=<factory>, prefix='', suffix='', separator='_')
Bases:
objectApplies a mapping to components and renames DataFrame columns accordingly.
- Variables:
- __init__(map=<factory>, convention=<factory>, _components=<factory>, prefix='', suffix='', separator='_')
Methods
__init__([map, convention, _components, ...])check()Checks if the map is ambiguous and raises an error if it is.
Creates a map of components to strings based on the convention.
default_column_name(component)Returns the default column name for a component.
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
componentsprefixseparatorsuffixmapconvention- 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