def subset_census_table(df, table_name, year, main_var):
    """
    Given an ACS table, subset it by variable and year.
    The ACS table must have these 7 columns at minimum:
        GEOID, table_name, year, main_var, second_var, new_var, num 

    table: pandas.DataFrame, the ACS table as a long df.
    table_name: str, such as "income" or "population".
    year: numeric, 2010-2018.
    main_var: str
        Only one value from the main_var column may be given.
    """
    cols = ["GEOID", "new_var", "num"]
    df = df[(df.year == year) & (df.table == table_name) & (df.main_var == main_var)][
        cols
    ]
    return df