pandas_vector_zone_translation#

caf.toolkit.translation.pandas_vector_zone_translation(vector: DataFrame, zone_correspondence: ZoneCorrespondence | DataFrame, translation_from_col: str = 'from', translation_to_col: str = 'to', translation_factors_col: str = 'factors', check_totals: bool = True, translation_dtype: dtype | None = None) DataFrame[source]#
caf.toolkit.translation.pandas_vector_zone_translation(vector: Series, zone_correspondence: ZoneCorrespondence | DataFrame, translation_from_col: str = 'from', translation_to_col: str = 'to', translation_factors_col: str = 'factors', check_totals: bool = True, translation_dtype: dtype | None = None) Series

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 (Series | DataFrame) – The vector to translate. The index must be the values to be translated.

  • zone_correspondence (ZoneCorrespondence | DataFrame) – A ZoneCorrespondence object defining the weights to translate use when translating.

  • translation_from_col (str = "from") – Name of zone ID column in translation which corresponds to the current vector zone ID. Deprecated, only provide if zone correspondence is a dataframe.

  • translation_to_col (str = "to") – Name of column in translation for the new zone IDs. Deprecated, only provide if zone correspondence is a dataframe.

  • translation_factors_col (str = "factors) – Name of column in translation. Deprecated, only provide if zone correspondence is a dataframe.

  • check_totals (bool) – Whether to check that the input and output matrices sum to the same total.

  • translation_dtype (dtype | None) – 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()