Fix the output of df.describe on an empty categorical / object column 
State: closed

- [x] closes #26397
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry


Labels:
name: Numeric Operations
description: Arithmetic, Comparison, and Logical operations

Comments:
Hello @enisnazif! Thanks for updating this PR. We checked the lines you've touched for [PEP 8](https://www.python.org/dev/peps/pep-0008) issues, and found:







There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers: 

##### Comment last updated at 2019-05-31 14:05:51 UTC
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26474?src=pr&el=h1) Report
> Merging [#26474](https://codecov.io/gh/pandas-dev/pandas/pull/26474?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/f5cc0789ae5f5a9e5b251e94784f537f30e0b490?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/26474/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/26474?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #26474      +/-   ##
==========================================
- Coverage   91.75%   91.74%   -0.01%     
==========================================
  Files         174      174              
  Lines       50765    50767       +2     
==========================================
- Hits        46578    46576       -2     
- Misses       4187     4191       +4
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.25% <100%> (ø)` | :arrow_up: |
| #single | `41.72% <0%> (-0.09%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26474?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/26474/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `93.49% <100%> (ø)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/26474/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `78.94% <0%> (-10.53%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/26474/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.02% <0%> (-0.12%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26474?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26474?src=pr&el=footer). Last update [f5cc078...10df157](https://codecov.io/gh/pandas-dev/pandas/pull/26474?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26474?src=pr&el=h1) Report
> Merging [#26474](https://codecov.io/gh/pandas-dev/pandas/pull/26474?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/7f318658b92155678b31780722277d1f8c8df569?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/26474/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/26474?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #26474      +/-   ##
==========================================
- Coverage   91.84%   91.84%   -0.01%     
==========================================
  Files         174      174              
  Lines       50644    50646       +2     
==========================================
- Hits        46516    46514       -2     
- Misses       4128     4132       +4
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.37% <100%> (ø)` | :arrow_up: |
| #single | `41.71% <0%> (-0.09%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26474?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/arrays/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/26474/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2NhdGVnb3JpY2FsLnB5) | `95.91% <100%> (ø)` | :arrow_up: |
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/26474/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `93.62% <100%> (ø)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/26474/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `78.94% <0%> (-10.53%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/26474/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97% <0%> (-0.12%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26474?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26474?src=pr&el=footer). Last update [7f31865...7100855](https://codecov.io/gh/pandas-dev/pandas/pull/26474?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

The test failure is from our job against NumPy master. 

```
        df = pd.DataFrame({"empty_col": Categorical([])})
>       result = df.describe()

pandas/tests/frame/test_analytics.py:594: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pandas/core/generic.py:9956: in describe
    ldesc = [describe_1d(s) for _, s in data.iteritems()]
pandas/core/generic.py:9956: in <listcomp>
    ldesc = [describe_1d(s) for _, s in data.iteritems()]
pandas/core/generic.py:9939: in describe_1d
    return describe_categorical_1d(data)
pandas/core/generic.py:9900: in describe_categorical_1d
    objcounts = data.value_counts()
pandas/core/base.py:1318: in value_counts
    normalize=normalize, bins=bins, dropna=dropna)
pandas/core/algorithms.py:689: in value_counts
    result = Series(values)._values.value_counts(dropna=dropna)
pandas/core/arrays/categorical.py:1480: in value_counts
    count = bincount(obs, minlength=ncat or None)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (array([], dtype=int8),), kwargs = {'minlength': None}
relevant_args = (array([], dtype=int8), None)

>   ???
E   DeprecationWarning: 0 should be passed as minlength instead of None; this will error in future.

```

I would see if Categorical.value_counts can be updated to pass `count = bincount(obs, minlength=ncat or 0)`. If that doesn't work for older numpy's then you'll need a bit more compat code.
> The test failure is from our job against NumPy master.
> 
> ```
>         df = pd.DataFrame({"empty_col": Categorical([])})
> >       result = df.describe()
> 
> pandas/tests/frame/test_analytics.py:594: 
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
> pandas/core/generic.py:9956: in describe
>     ldesc = [describe_1d(s) for _, s in data.iteritems()]
> pandas/core/generic.py:9956: in <listcomp>
>     ldesc = [describe_1d(s) for _, s in data.iteritems()]
> pandas/core/generic.py:9939: in describe_1d
>     return describe_categorical_1d(data)
> pandas/core/generic.py:9900: in describe_categorical_1d
>     objcounts = data.value_counts()
> pandas/core/base.py:1318: in value_counts
>     normalize=normalize, bins=bins, dropna=dropna)
> pandas/core/algorithms.py:689: in value_counts
>     result = Series(values)._values.value_counts(dropna=dropna)
> pandas/core/arrays/categorical.py:1480: in value_counts
>     count = bincount(obs, minlength=ncat or None)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
> 
> args = (array([], dtype=int8),), kwargs = {'minlength': None}
> relevant_args = (array([], dtype=int8), None)
> 
> >   ???
> E   DeprecationWarning: 0 should be passed as minlength instead of None; this will error in future.
> ```
> 
> I would see if Categorical.value_counts can be updated to pass `count = bincount(obs, minlength=ncat or 0)`. If that doesn't work for older numpy's then you'll need a bit more compat code.

Ok, thanks - I'll take a look
@enisnazif can you add a note in the api breaking section
> @enisnazif can you add a note in the api breaking section

Done

> doc comment; ping on green.
 @jreback checks have all passed, ok to merge?

i'll take a look at the failing jobs
@enisnazif that's fixed on master. Just merged & repushed. Ping on green.
> @enisnazif that's fixed on master. Just merged & repushed. Ping on green.

@jreback @TomAugspurger hey, looks like it's green. Is it good to merge?
thanks @enisnazif