<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _yield_spatial_table(patch, div, spp_col, count_col, x_col, y_col):
 """ Calculates an empirical spatial table Yields ------- DataFrame Spatial table for each division. See Notes. Notes ----- The spatial table is the precursor to the SAR, EAR, and grid-based commonality metrics. Each row in the table corresponds to a cell created by a given division. Columns are cell_loc (within the grid defined by the division), spp_set, n_spp, and n_individs. """


    # Catch error if you don't use ; after divs in comm_grid in MacroecoDesktop
    try:
        div_split_list = div.replace(';','').split(',')
    except AttributeError:
        div_split_list = str(div).strip("()").split(',')

    div_split = (x_col + ':' + div_split_list[0] + ';' +
                 y_col + ':' + div_split_list[1])

    # Get cell_locs
    # Requires _parse_splits and _product functions to go y inside of x
    x_starts, x_ends = _col_starts_ends(patch, x_col, div_split_list[0])
    x_offset = (x_ends[0] - x_starts[0]) / 2
    x_locs = x_starts + x_offset

    y_starts, y_ends = _col_starts_ends(patch, y_col, div_split_list[1])
    y_offset = (y_ends[0] - y_starts[0]) / 2
    y_locs = y_starts + y_offset

    cell_locs = _product(x_locs, y_locs)

    # Get spp set and count for all cells
    n_spp_list = [] # Number of species in cell
    n_individs_list = []
    spp_set_list = []   # Set object giving unique species IDs in cell
    for cellstring, cellpatch in _yield_subpatches(patch,div_split,name='div'):
        spp_set = set(np.unique(cellpatch.table[spp_col]))
        spp_set_list.append(spp_set)
        n_spp_list.append(len(spp_set))
        n_individs_list.append(np.sum(cellpatch.table[count_col]))

    # Create and return dataframe
    df = pd.DataFrame({'cell_loc': cell_locs, 'spp_set': spp_set_list,
                       'n_spp': n_spp_list, 'n_individs': n_individs_list})

    return df