def get_counts_by_tract(mf_with_tract, output_col_name):
    """Return a dataframe containing the the mortgage foreclosure counts by Census Tract by year.

    Parameters
    ----------
    mf_with_parcels : pandas df
        Mortgage foreclosure data, where each row represents a foreclosed property and its parcel
        ID

    Returns
    -------
    pandas df
        Dataframe with columns ['year', 'GEOID', 'num_mortgage_foreclosures']
    """
    
    # Get the counts by census tract by year
    counts_by_ct_by_year = mf_with_tract.groupby(["year", "GEOID"]).size().to_frame('num').reset_index()

    # Reset index to add year column & clean up
    mf_counts_by_ct = (
        counts_by_ct_by_year
        .rename(columns={"num": output_col_name},) # "num_mortgage_foreclosures" or "lien-foreclosures"
    )
    return mf_counts_by_ct