DEPR: Deprecate NDFrame.as_matrix
State: closed

- [x ] xref #18262
- [x ] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ x] whatsnew entry

Deprecating ``NDFrame.as_matrix`` as per discussion in #18262.

Labels:
name: Deprecate
description: Functionality to remove in pandas

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

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

```diff
@@            Coverage Diff             @@
##           master   #18458      +/-   ##
==========================================
+ Coverage    91.3%   91.32%   +0.02%     
==========================================
  Files         163      163              
  Lines       49781    49783       +2     
==========================================
+ Hits        45451    45464      +13     
+ Misses       4330     4319      -11
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.12% <85.71%> (+0.02%)` | :arrow_up: |
| #single | `40.72% <64.28%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/18458?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/panel.py](https://codecov.io/gh/pandas-dev/pandas/pull/18458?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcGFuZWwucHk=) | `96.85% <0%> (-0.29%)` | :arrow_down: |
| [pandas/core/internals.py](https://codecov.io/gh/pandas-dev/pandas/pull/18458?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzLnB5) | `94.47% <100%> (ø)` | :arrow_up: |
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/18458?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `95.78% <83.33%> (+0.05%)` | :arrow_up: |
| [pandas/plotting/\_converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/18458?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb252ZXJ0ZXIucHk=) | `65.25% <0%> (+1.81%)` | :arrow_up: |

------

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

General question: I am wondering if we shouldn't rather recommend to do `np.asarray(df)` instead of `df.values` ?
Interesting, does it conform to ``.values`` in all cases?.

Anyway, I suggest that that will be a separate issue from this one.
I've changed the PR according to the comments. Is this ok?
A thought: ``BlockManager.as_matrix`` is a strange name as it implies a np.matrix is returned.

Should I not just change it to ``BlockManager.as_array``? Or, do any external libraries rely on calling BlockManager directly, e.g. statsmodel?
@topper-123 ok this lgtm. ping on green.
> Should I not just change it to BlockManager.as_array? Or, do any external libraries rely on calling BlockManager directly, e.g. statsmodel?

this is completely private and internal. ``as_array`` would be fine. while you are at it, can you add a doc-string.

ping when ready.
All green, @jreback 
thanks @topper-123