import re


def extract_sic_code_description(table, var_name):
    """Extracts codes and descriptions from SIC table
    Args:
        table (pandas.DataFrame): summary of the SIC taxonomy
        var_name (str): level of SIC we want to extract a lookup for
    Returns:
        A lookup between the variable codes and their description
    """
    loc = list(table.columns).index(var_name)  # Find the location of class
    select = table.iloc[:, [loc, loc + 1]].dropna()  # Extract variable & description
    select.columns = [var_name, "description"]

    select[var_name] = [re.sub(r"\.", "", str(x)) for x in select[var_name]]
    return select.set_index(var_name)["description"].to_dict()