pandas_vector_zone_translation#

translation.pandas_vector_zone_translation(vector, translation, translation_from_col, translation_to_col, translation_factors_col, from_unique_index, to_unique_index, translation_dtype=None, vector_infill=0.0, translate_infill=0.0, check_totals=True)#

Efficiently translates a pandas vector between index systems.

Internally, checks and converts the pandas inputs into numpy arrays and calls numpy_vector_zone_translation(). The final output is then converted back into a pandas Series, using the same format as the input.

Parameters:
  • vector (Series | DataFrame) – The vector to translate. The index must be the values to be translated.

  • translation (DataFrame) – 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 (str) – The name of the column in translation containing the current index values of vector.

  • translation_to_col (str) – The name of the column in translation containing the desired output index values. This will define the output index format.

  • translation_factors_col (str) – 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.

  • from_unique_index (list[Any]) – A list of all the unique IDs in the input indexing system.

  • to_unique_index (list[Any]) – A list of all the unique IDs in the output indexing system.

  • 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.

  • vector_infill (float) – The value to use to infill any missing vector values.

  • translate_infill (float) – The value to use to infill any missing translation factors.

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

Returns:

vector, translated into to_zone system.

Return type:

translated_vector