# Buggy code
def drop(self, labels, errors="raise"):
    """Drop the specified labels from the IndexMetadata

    Args:
        labels (scalar or list-like):
            The labels to drop
        errors ('raise' or 'ignore'):
            If 'ignore', suppress errors for when labels don't exist

    Returns:
        DataFrame with coordinates of dropped labels
    """
    dropped = self.coords_of(labels)

    # Update first lengths to prevent possible length inconsistencies
    if isinstance(dropped, pd.DataFrame):
        drop_per_part = (
            dropped.groupby(["partition"])
            .size()
            .reindex(index=pd.RangeIndex(len(self._lengths)), fill_value=0)
        )
    elif isinstance(dropped, pd.Series):
        drop_per_part = np.zeros_like(self._lengths)
        drop_per_part[dropped["partition"]] = 1
    else:
        raise AssertionError("Unrecognized result from `coords_of`")
    self._lengths = self._lengths - drop_per_part

    self._coord_df = self._coord_df.drop(labels, errors=errors)
    return dropped


# Traceback (IndexError)
Remote function ray.dataframe.utils._deploy_func failed with:

Traceback (most recent call last):
File "/home/peter/workspace/ray/python/ray/dataframe/utils.py", line 132, in _deploy_func
return func(dataframe, *args)
File "/home/peter/workspace/ray/python/ray/dataframe/dataframe.py", line 4728, in del_helper
cols = df.columns[to_delete]  # either int or an array of ints
File "/home/peter/workspace/ray_env/lib/python3.6/site-packages/pandas/core/indexes/range.py", line 544, in __getitem__
return super_getitem(key)
File "/home/peter/workspace/ray_env/lib/python3.6/site-packages/pandas/core/indexes/base.py", line 1754, in __getitem__
result = getitem(key)
IndexError: index 0 is out of bounds for axis 1 with size 0


You can inspect errors by running

ray.error_info()

If this driver is hanging, start a new one with

ray.init(redis_address="192.168.0.114:49682")

# Fixed code
def drop(self, labels, errors="raise"):
    """Drop the specified labels from the IndexMetadata

    Args:
        labels (scalar or list-like):
            The labels to drop
        errors ('raise' or 'ignore'):
            If 'ignore', suppress errors for when labels don't exist

    Returns:
        DataFrame with coordinates of dropped labels
    """
    dropped = self.coords_of(labels)

    # Update first lengths to prevent possible length inconsistencies
    if isinstance(dropped, pd.DataFrame):
        try:
            drop_per_part = (
                dropped.groupby(["partition"])
                .size()
                .reindex(index=pd.RangeIndex(len(self._lengths)), fill_value=0)
            )
        except ValueError:
            # Copy the arrow sealed dataframe so we can mutate it.
            dropped = dropped.copy()
            drop_per_part = (
                dropped.groupby(["partition"])
                .size()
                .reindex(index=pd.RangeIndex(len(self._lengths)), fill_value=0)
            )
    elif isinstance(dropped, pd.Series):
        drop_per_part = np.zeros_like(self._lengths)
        drop_per_part[dropped["partition"]] = 1
    else:
        raise AssertionError("Unrecognized result from `coords_of`")
    self._lengths = self._lengths - drop_per_part

    self._coord_df = self._coord_df.drop(labels, errors=errors)
    return dropped