API: Standard signature for to_numpy
State: closed

This is part 1 of https://github.com/pandas-dev/pandas/issues/23995

We make the signature

`to_numpy(dtype : Union[str, np.dtype], copy : bool) -> ndarray`

Labels:
name: ExtensionArray
description: Extending pandas with custom dtypes or arrays.

Comments:
Hello @TomAugspurger! Thanks for submitting the PR.

 - There are no PEP8 issues in the file [`pandas/core/base.py`](https://github.com/TomAugspurger/pandas/blob/a2dd343b4e517e9a54a61ad4dab17fd73a5d1829/pandas/core/base.py) !

 - There are no PEP8 issues in the file [`pandas/core/frame.py`](https://github.com/TomAugspurger/pandas/blob/a2dd343b4e517e9a54a61ad4dab17fd73a5d1829/pandas/core/frame.py) !

 - There are no PEP8 issues in the file [`pandas/tests/frame/test_api.py`](https://github.com/TomAugspurger/pandas/blob/a2dd343b4e517e9a54a61ad4dab17fd73a5d1829/pandas/tests/frame/test_api.py) !

 - There are no PEP8 issues in the file [`pandas/tests/indexes/multi/test_conversion.py`](https://github.com/TomAugspurger/pandas/blob/a2dd343b4e517e9a54a61ad4dab17fd73a5d1829/pandas/tests/indexes/multi/test_conversion.py) !

 - There are no PEP8 issues in the file [`pandas/tests/test_base.py`](https://github.com/TomAugspurger/pandas/blob/a2dd343b4e517e9a54a61ad4dab17fd73a5d1829/pandas/tests/test_base.py) !


# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24341?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@f57c357`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff            @@
##             master   #24341   +/-   ##
=========================================
  Coverage          ?   92.28%           
=========================================
  Files             ?      162           
  Lines             ?    51821           
  Branches          ?        0           
=========================================
  Hits              ?    47824           
  Misses            ?     3997           
  Partials          ?        0
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.69% <100%> (?)` | |
| #single | `42.98% <22.22%> (?)` | |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24341?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/24341/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYmFzZS5weQ==) | `97.66% <100%> (ø)` | |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/24341/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.91% <100%> (ø)` | |

------

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

Yep, that was my inspiration.

On Tue, Dec 18, 2018 at 4:26 PM Jeff Reback <notifications@github.com>
wrote:

> *@jreback* commented on this pull request.
> ------------------------------
>
> In pandas/core/base.py
> <https://github.com/pandas-dev/pandas/pull/24341#discussion_r242729390>:
>
> >          """
>          if (is_extension_array_dtype(self.dtype) or
>                  is_datetime64tz_dtype(self.dtype)):
>              # TODO(DatetimeArray): remove the second clause.
> -            return np.asarray(self._values)
> -        return self._values
> +            result = np.asarray(self._values, dtype=dtype)
>
> no ok for now, though maybe add a comment. note that @jbrockmendel
> <https://github.com/jbrockmendel> basically does this in the in various
> parts of the datetimelike constructors.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/24341#discussion_r242729390>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABQHIrKu8GRAWPkGAr4QfXKr4km-yrkDks5u6WuugaJpZM4ZY-Ou>
> .
>

thanks!