BUG: Fix Series.astype and Categorical.astype to update existing Categorical data
State: closed

- [X] closes #10696
- [X] closes #18593
- [X] tests added / passed
- [X] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [X] whatsnew entry

Couldn't find an issue about it, but the same problem described with `Series.astype` in the linked issues was occurring with `Categorical.astype`.  Put in a fix for that too with some code very similar to what was done in #18677 for `CategoricalIndex.astype`.  Could probably consolidate the two into a single helper function, potentially as part of #18704.

Labels:
name: Bug
name: Dtype Conversions
description: Unexpected or buggy dtype conversions
name: Categorical
description: Categorical Data Type

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

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

```diff
@@            Coverage Diff             @@
##           master   #18710      +/-   ##
==========================================
- Coverage   91.61%   91.59%   -0.03%     
==========================================
  Files         153      153              
  Lines       51363    51359       -4     
==========================================
- Hits        47058    47044      -14     
- Misses       4305     4315      +10
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.46% <100%> (-0.01%)` | :arrow_down: |
| #single | `40.77% <84.61%> (-0.11%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/18710?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/18710/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY2F0ZWdvcmljYWwucHk=) | `95.79% <100%> (+0.14%)` | :arrow_up: |
| [pandas/core/internals.py](https://codecov.io/gh/pandas-dev/pandas/pull/18710/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzLnB5) | `94.42% <100%> (-0.02%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/18710/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/18710/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `82.32% <0%> (-0.2%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/18710/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.81% <0%> (-0.1%)` | :arrow_down: |

------

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

give this a rebase and use ``_update_dtype``
Rebased and used `_update_dtype`.

Will write up an issue in the next day or so to discuss the behavior of `.astype('category')` on existing categorical data, extending on the discussion that took place further up in the code review comments.
Updated to remove the unnecessary `copy` parametrize.  Removed an additional instance of this that was introduced in  #18677.
thanks @jschendel nice patches! keep em coming!