BUG: dropna incorrect with categoricals in pivot_table
State: closed

closes #21133


Labels:
name: Bug
name: Groupby
name: Categorical
description: Categorical Data Type

Comments:
would appreciate a look @WillAyd @jschendel @TomAugspurger @jorisvandenbossche 
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21252?src=pr&el=h1) Report
> Merging [#21252](https://codecov.io/gh/pandas-dev/pandas/pull/21252?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/c460710f32193c65e33d366921f9eaf919bc8da4?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/21252/graphs/tree.svg?width=650&height=150&src=pr&token=eZ4WkYLtcO)](https://codecov.io/gh/pandas-dev/pandas/pull/21252?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #21252      +/-   ##
==========================================
- Coverage   91.85%   91.85%   -0.01%     
==========================================
  Files         153      153              
  Lines       49564    49561       -3     
==========================================
- Hits        45527    45524       -3     
  Misses       4037     4037
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.25% <100%> (-0.01%)` | :arrow_down: |
| #single | `41.87% <25%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/21252?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/reshape/pivot.py](https://codecov.io/gh/pandas-dev/pandas/pull/21252/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcmVzaGFwZS9waXZvdC5weQ==) | `97.03% <100%> (+0.05%)` | :arrow_up: |
| [pandas/io/formats/style.py](https://codecov.io/gh/pandas-dev/pandas/pull/21252/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvc3R5bGUucHk=) | `96.03% <0%> (-0.09%)` | :arrow_down: |
| [pandas/core/reshape/melt.py](https://codecov.io/gh/pandas-dev/pandas/pull/21252/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcmVzaGFwZS9tZWx0LnB5) | `97.34% <0%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21252?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/21252?src=pr&el=footer). Last update [c460710...683fd9e](https://codecov.io/gh/pandas-dev/pandas/pull/21252?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

I've tried this PR on #21151. This does not solve that issue, though the bugs in the two issues seem very similar.
updated, if you'd have another look
this is complicated 
i don’t think will get to this for 0.23.1
Then let's revert the changes to `pivot` for now? (not the addition of `observed` keyword to groupby! I mean only the internal use of it inside `pivot`)
I think its prob ok to merge this particular commit (even if susequently change for #21151) or leave this all for 0.23.2
> I think its prob ok to merge this particular commit

Ah, yes, that's actually basically the same as reverting the change to pivot. 
Merging then.