Translate between full state names and abbreviations

plot_utils._translate_state_abbrev(dict1, abbrev_to_full=True)[source]

Convert state full names into state abbreviations, or the other way. Overseas territories (except Puerto Rico) cannot be converted.

Robustness is not guaranteed: if invalide state names (full or abbreviated) exist in dict1, a KeyError will be raised.

Parameters:
  • dict1 (dict) – A mapping between state name and some data, e.g., {‘AK’: 1, ‘AL’: 2, …}

  • abbrev_to_full (bool) – If True, translate {‘AK’: 1, ‘AL’: 2, …} into {‘Alaska’: 1, ‘Alabama’: 2, …}. If False, the opposite way.

Returns:

dict2 – The converted dictionary

Return type:

dict