pandas_vector_zone_translation#
- caf.toolkit.translation.pandas_vector_zone_translation(vector: Series, translation: DataFrame, translation_from_col: str, translation_to_col: str, translation_factors_col: str, check_totals: bool = True, translation_dtype: dtype | None = None) Series [source]#
- caf.toolkit.translation.pandas_vector_zone_translation(vector: DataFrame, translation: DataFrame, translation_from_col: str, translation_to_col: str, translation_factors_col: str, check_totals: bool = True, translation_dtype: dtype | None = None) DataFrame
Efficiently translate a pandas vector between index systems.
Works for either single (Series) or multi (DataFrame) columns data vectors. Essentially switches between pandas_single_vector_zone_translation() and pandas_multi_vector_zone_translation().
- Parameters:
vector – The vector to translate. The index must be the values to be translated.
translation – A pandas DataFrame defining the weights to translate use when translating. Needs to contain columns: translation_from_col, translation_to_col, translation_factors_col.
translation_from_col – The name of the column in translation containing the current index values of vector.
translation_to_col – The name of the column in translation containing the desired output index values. This will define the output index format.
translation_factors_col – The name of the column in translation containing the translation weights between translation_from_col and translation_to_col. Where zone pairs do not exist, they will be infilled with translate_infill.
check_totals – Whether to check that the input and output matrices sum to the same total.
translation_dtype – The numpy datatype to use to do the translation. If None, then the dtype of vector is used. Where such high precision isn’t needed, a more memory and time efficient data type can be used.
- Returns:
vector, translated into to_zone system.
- Return type:
translated_vector
See also
pandas_single_vector_zone_translation() pandas_multi_vector_zone_translation()