Repository: dask/dask

Issue:
BUG/DOC: reset_index(drop=True) is not supported
> 0.11.1

should be supported according to docs:
http://dask.pydata.org/en/latest/dataframe-api.html#dask.dataframe.DataFrame.reset_index

```
In [27]: ddf = dd.from_pandas(pd.DataFrame({'A' : [1,2,3], 'B' : [1, 2, 3]}), npartitions=3)

In [28]: ddf.reset_index().compute()
Out[28]:
   index  A  B
0      0  1  1
0      1  2  2
1      2  3  3

In [29]: ddf.reset_index(drop=True).compute()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-29-d8e871a6684b> in <module>()
----> 1 ddf.reset_index(drop=True).compute()

TypeError: reset_index() got an unexpected keyword argument 'drop'

```



Discussion:

Resolving patch:
diff --git a/dask/dataframe/core.py b/dask/dataframe/core.py
--- a/dask/dataframe/core.py
+++ b/dask/dataframe/core.py
@@ -299,6 +299,10 @@ def index(self):
         return Index(merge(dsk, self.dask), name,
                      self._meta.index, self.divisions)
 
+    @derived_from(pd.DataFrame)
+    def reset_index(self, drop=False):
+        return self.map_partitions(M.reset_index, drop=drop).clear_divisions()
+
     @property
     def known_divisions(self):
         """Whether divisions are already known"""
@@ -1517,6 +1521,10 @@ def dt(self):
         from .accessor import DatetimeAccessor
         return DatetimeAccessor(self)
 
+    @derived_from(pd.Series)
+    def reset_index(self, drop=False):
+        return super(Series, self).reset_index(drop=drop)
+
     @cache_readonly
     def cat(self):
         from .accessor import CategoricalAccessor
@@ -2075,12 +2083,6 @@ def nlargest(self, n=5, columns=None, split_every=None):
                    meta=self._meta, token=token, split_every=split_every,
                    n=n, columns=columns)
 
-    @derived_from(pd.DataFrame)
-    def reset_index(self):
-        out = self.map_partitions(M.reset_index)
-        out.divisions = [None] * (self.npartitions + 1)
-        return out
-
     @derived_from(pd.DataFrame)
     def groupby(self, key, **kwargs):
         from dask.dataframe.groupby import DataFrameGroupBy
diff --git a/dask/dataframe/utils.py b/dask/dataframe/utils.py
--- a/dask/dataframe/utils.py
+++ b/dask/dataframe/utils.py
@@ -413,7 +413,7 @@ def _maybe_sort(a):
 
 
 def assert_eq(a, b, check_names=True, check_dtypes=True,
-              check_divisions=True, **kwargs):
+              check_divisions=True, check_index=True, **kwargs):
     if check_divisions:
         assert_divisions(a)
         assert_divisions(b)
@@ -421,6 +421,9 @@ def assert_eq(a, b, check_names=True, check_dtypes=True,
     assert_sane_keynames(b)
     a = _check_dask(a, check_names=check_names, check_dtypes=check_dtypes)
     b = _check_dask(b, check_names=check_names, check_dtypes=check_dtypes)
+    if not check_index:
+        a = a.reset_index(drop=True)
+        b = b.reset_index(drop=True)
     if isinstance(a, pd.DataFrame):
         a = _maybe_sort(a)
         b = _maybe_sort(b)


Test patch:
diff --git a/dask/dataframe/tests/test_dataframe.py b/dask/dataframe/tests/test_dataframe.py
--- a/dask/dataframe/tests/test_dataframe.py
+++ b/dask/dataframe/tests/test_dataframe.py
@@ -2095,12 +2095,25 @@ def test_reset_index():
     df = pd.DataFrame({'x': [1, 2, 3, 4], 'y': [10, 20, 30, 40]})
     ddf = dd.from_pandas(df, npartitions=2)
 
+    sol = df.reset_index()
     res = ddf.reset_index()
-    exp = df.reset_index()
-
-    assert len(res.index.compute()) == len(exp.index)
-    tm.assert_index_equal(res.columns, exp.columns)
-    tm.assert_numpy_array_equal(res.compute().values, exp.values)
+    assert all(d is None for d in res.divisions)
+    assert_eq(res, sol, check_index=False)
+
+    sol = df.reset_index(drop=True)
+    res = ddf.reset_index(drop=True)
+    assert all(d is None for d in res.divisions)
+    assert_eq(res, sol, check_index=False)
+
+    sol = df.x.reset_index()
+    res = ddf.x.reset_index()
+    assert all(d is None for d in res.divisions)
+    assert_eq(res, sol, check_index=False)
+
+    sol = df.x.reset_index(drop=True)
+    res = ddf.x.reset_index(drop=True)
+    assert all(d is None for d in res.divisions)
+    assert_eq(res, sol, check_index=False)
 
 
 def test_dataframe_compute_forward_kwargs():