def _translate_state_abbrev(dict1, abbrev_to_full=True):
    """
    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 : dict
        The converted dictionary
    """
    assert isinstance(dict1, dict)
    if abbrev_to_full is True:
        translation = {'AK': 'Alaska', 'AL': 'Alabama', 'AR': 'Arkansas',
            'AS': 'American Samoa', 'AZ': 'Arizona', 'CA': 'California',
            'CO': 'Colorado', 'CT': 'Connecticut', 'DC':
            'District of Columbia', 'DE': 'Delaware', 'FL': 'Florida', 'GA':
            'Georgia', 'GU': 'Guam', 'HI': 'Hawaii', 'IA': 'Iowa', 'ID':
            'Idaho', 'IL': 'Illinois', 'IN': 'Indiana', 'KS': 'Kansas',
            'KY': 'Kentucky', 'LA': 'Louisiana', 'MA': 'Massachusetts',
            'MD': 'Maryland', 'ME': 'Maine', 'MI': 'Michigan', 'MN':
            'Minnesota', 'MO': 'Missouri', 'MP': 'Northern Mariana Islands',
            'MS': 'Mississippi', 'MT': 'Montana', 'NA': 'National', 'NC':
            'North Carolina', 'ND': 'North Dakota', 'NE': 'Nebraska', 'NH':
            'New Hampshire', 'NJ': 'New Jersey', 'NM': 'New Mexico', 'NV':
            'Nevada', 'NY': 'New York', 'OH': 'Ohio', 'OK': 'Oklahoma',
            'OR': 'Oregon', 'PA': 'Pennsylvania', 'PR': 'Puerto Rico', 'RI':
            'Rhode Island', 'SC': 'South Carolina', 'SD': 'South Dakota',
            'TN': 'Tennessee', 'TX': 'Texas', 'UT': 'Utah', 'VA':
            'Virginia', 'VI': 'Virgin Islands', 'VT': 'Vermont', 'WA':
            'Washington', 'WI': 'Wisconsin', 'WV': 'West Virginia', 'WY':
            'Wyoming'}
    else:
        translation = {'Alabama': 'AL', 'Alaska': 'AK', 'Arizona': 'AZ',
            'Arkansas': 'AR', 'California': 'CA', 'Colorado': 'CO',
            'Connecticut': 'CT', 'Delaware': 'DE', 'District of Columbia':
            'DC', 'Florida': 'FL', 'Georgia': 'GA', 'Hawaii': 'HI', 'Idaho':
            'ID', 'Illinois': 'IL', 'Indiana': 'IN', 'Iowa': 'IA', 'Kansas':
            'KS', 'Kentucky': 'KY', 'Louisiana': 'LA', 'Maine': 'ME',
            'Maryland': 'MD', 'Massachusetts': 'MA', 'Michigan': 'MI',
            'Minnesota': 'MN', 'Mississippi': 'MS', 'Missouri': 'MO',
            'Montana': 'MT', 'Nebraska': 'NE', 'Nevada': 'NV',
            'New Hampshire': 'NH', 'New Jersey': 'NJ', 'New Mexico': 'NM',
            'New York': 'NY', 'North Carolina': 'NC', 'North Dakota': 'ND',
            'Ohio': 'OH', 'Oklahoma': 'OK', 'Oregon': 'OR', 'Pennsylvania':
            'PA', 'Puerto Rico': 'PR', 'Rhode Island': 'RI',
            'South Carolina': 'SC', 'South Dakota': 'SD', 'Tennessee': 'TN',
            'Texas': 'TX', 'Utah': 'UT', 'Vermont': 'VT', 'Virginia': 'VA',
            'Washington': 'WA', 'West Virginia': 'WV', 'Wisconsin': 'WI',
            'Wyoming': 'WY'}
    dict2 = {}
    for state_name in dict1:
        new_state_name = translation[state_name]
        dict2.update({new_state_name: dict1[state_name]})
    return dict2
