def _select_closest(to_search_df, target_series):
    """
    Find row in ``to_search_df`` that is closest to the target array.

    Here, 'closest' is in the root-mean squared sense. In the event that multiple rows
    are equally close, returns first row.

    Parameters
    ----------
    to_search_df : :obj:`pd.DataFrame`
        The rows of this dataframe are the candidate closest vectors

    target_series : :obj:`pd.Series`
        The vector to which we want to be close

    Returns
    -------
    dict
        Metadata of the closest row.
    """
    if len(target_series.shape) != 1:
        raise ValueError("Target array is multidimensional")

    if target_series.shape[0] != to_search_df.shape[1]:
        raise ValueError(
            "Target array does not match the size of the searchable arrays"
        )

    closeness = []
    for label, row in to_search_df.iterrows():
        rms = (((target_series - row) ** 2).mean()) ** 0.5
        closeness.append((label, rms))

    # Find the minimum closeness and return the index of it
    labels, rmss = list(zip(*closeness))
    to_return = rmss.index(min(rmss))
    return dict(zip(to_search_df.index.names, labels[to_return]))