BUG: Categorical.copy deep kwarg
State: closed

Would close #26995 if I hadn't just updated that to reflect the fact that several other pandas-internal EAs don't handle the `deep` kwarg correctly.

- [ ] closes #xxxx
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry


Labels:
name: Algos
description: Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff
name: Categorical
description: Categorical Data Type

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

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

```diff
@@            Coverage Diff             @@
##           master   #27024      +/-   ##
==========================================
+ Coverage   91.99%      92%   +<.01%     
==========================================
  Files         180      180              
  Lines       50774    50760      -14     
==========================================
- Hits        46712    46703       -9     
+ Misses       4062     4057       -5
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.64% <100%> (+0.01%)` | :arrow_up: |
| #single | `41.86% <56.25%> (-0.05%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/27024?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/arrays/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/27024/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2NhdGVnb3JpY2FsLnB5) | `95.94% <100%> (+0.02%)` | :arrow_up: |
| [pandas/core/internals/blocks.py](https://codecov.io/gh/pandas-dev/pandas/pull/27024/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL2Jsb2Nrcy5weQ==) | `94.62% <100%> (+0.24%)` | :arrow_up: |
| [pandas/core/internals/construction.py](https://codecov.io/gh/pandas-dev/pandas/pull/27024/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL2NvbnN0cnVjdGlvbi5weQ==) | `95.95% <100%> (ø)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/27024/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `88.88% <0%> (-11.12%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/27024/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.89% <0%> (-0.12%)` | :arrow_down: |
| [pandas/core/ops.py](https://codecov.io/gh/pandas-dev/pandas/pull/27024/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvb3BzLnB5) | `94.66% <0%> (-0.03%)` | :arrow_down: |
| [pandas/core/indexes/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/27024/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZWxpa2UucHk=) | `98.14% <0%> (-0.01%)` | :arrow_down: |
| [pandas/io/formats/format.py](https://codecov.io/gh/pandas-dev/pandas/pull/27024/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvZm9ybWF0LnB5) | `97.91% <0%> (ø)` | :arrow_up: |
| [pandas/core/sorting.py](https://codecov.io/gh/pandas-dev/pandas/pull/27024/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc29ydGluZy5weQ==) | `98.35% <0%> (ø)` | :arrow_up: |
| [pandas/core/arrays/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/27024/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2Jhc2UucHk=) | `99.43% <0%> (ø)` | :arrow_up: |
| ... and [7 more](https://codecov.io/gh/pandas-dev/pandas/pull/27024/diff?src=pr&el=tree-more) | |

------

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

What was the decision in the issue? I thought we were tending toward deprecating `deep` in `ExtensionArray.copy`, but I may be wrong.
> What was the decision in the issue? I thought we were tending toward deprecating deep in ExtensionArray.copy, but I may be wrong.

I don't think a decision has been reached there (though I agree with your assessment of the momentum).  Until/unless that change is made, this is the right move.  Largely motivated by wanting to clear road-blocks to #27015.
yeah let's not add the deep kwarg on EA .copy(), it doesn't really make sense; we may actually be able to deprecate it entirely on Series/DataFrame as well (separate issue).
> yeah let's not add the deep kwarg on EA .copy()

The issue is that EA already has the deep, kwarg, but Categorical doesn't.  I'm pretty sure that this will fix some latent bugs for other EAs, will check and add tests if so.
Superceded by https://github.com/pandas-dev/pandas/pull/27083