def _sub_expand_grid(value, grid_index):  # noqa: F811
    """
    Expands the Index based on `grid_index`.

    Returns a DataFrame (if MultiIndex), or a Series.
    """
    if value.empty:
        raise ValueError("""Index cannot be empty.""")

    value = value[grid_index]

    return value.to_frame(index=False)