Repository: dask/dask

Issue:
dask.dataframe.describe fails with all object columns
From [SO](http://stackoverflow.com/questions/43895873/dask-eror-min-arg-is-an-empty-sequence)

```python
In [14]: df = pd.DataFrame({"A": ['a', 'b', 'c', 'd', 'e']})

In [15]: import pandas as pd; import dask.dataframe as dd

In [16]: df = pd.DataFrame({"A": ['a', 'b', 'c', 'd', 'e']})

In [17]: dd.from_pandas(df, 2).describe().compute()
```

```pytb
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-17-48df04528427> in <module>()
----> 1 dd.from_pandas(df, 2).describe().compute()

/Users/taugspurger/.virtualenvs/pandas-dev/lib/python3.6/site-packages/dask/dataframe/core.py in describe(self, split_every)
   1305         num = self._get_numeric_data()
   1306
-> 1307         stats = [num.count(split_every=split_every),
   1308                  num.mean(split_every=split_every),
   1309                  num.std(split_every=split_every),

/Users/taugspurger/.virtualenvs/pandas-dev/lib/python3.6/site-packages/dask/dataframe/core.py in count(self, axis, split_every)
   1190                                     token=token, split_every=split_every)
   1191             if isinstance(self, DataFrame):
-> 1192                 result.divisions = (min(self.columns), max(self.columns))
   1193             return result
   1194

ValueError: min() arg is an empty sequence

```

I can take a look later.


Discussion:
Ah interesting, `.describe` only computes on numeric data. We can probably have a better error message here anyway.

Resolving patch:
diff --git a/dask/dataframe/core.py b/dask/dataframe/core.py
--- a/dask/dataframe/core.py
+++ b/dask/dataframe/core.py
@@ -1304,6 +1304,10 @@ def quantile(self, q=0.5, axis=0):
     def describe(self, split_every=False):
         # currently, only numeric describe is supported
         num = self._get_numeric_data()
+        if self.ndim == 2 and len(num.columns) == 0:
+            raise ValueError("DataFrame contains only non-numeric data.")
+        elif self.ndim == 1 and self.dtype == 'object':
+            raise ValueError("Cannot compute ``describe`` on object dtype.")
 
         stats = [num.count(split_every=split_every),
                  num.mean(split_every=split_every),


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
@@ -254,6 +254,18 @@ def test_describe():
     assert_eq(df.describe(), ddf.describe(split_every=2))
 
 
+def test_describe_empty():
+    # https://github.com/dask/dask/issues/2326
+    ddf = dd.from_pandas(pd.DataFrame({"A": ['a', 'b']}), 2)
+    with pytest.raises(ValueError) as rec:
+        ddf.describe()
+    assert rec.match('DataFrame contains only non-numeric data.')
+
+    with pytest.raises(ValueError) as rec:
+        ddf.A.describe()
+    assert rec.match('Cannot compute ``describe`` on object dtype.')
+
+
 def test_cumulative():
     df = pd.DataFrame(np.random.randn(100, 5), columns=list('abcde'))
     ddf = dd.from_pandas(df, 5)