Added Datetime & Timedelta inference to array
State: closed

Closes https://github.com/pandas-dev/pandas/issues/24568

Labels:
name: API Design

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

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

```diff
@@             Coverage Diff             @@
##           master   #24571       +/-   ##
===========================================
- Coverage   92.31%   43.07%   -49.25%     
===========================================
  Files         166      166               
  Lines       52556    52563        +7     
===========================================
- Hits        48518    22640    -25878     
- Misses       4038    29923    +25885
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `?` | |
| #single | `43.07% <0%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24571?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/arrays/array\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/24571/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2FycmF5Xy5weQ==) | `12.82% <0%> (-87.18%)` | :arrow_down: |
| [pandas/io/formats/latex.py](https://codecov.io/gh/pandas-dev/pandas/pull/24571/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvbGF0ZXgucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/core/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/24571/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY2F0ZWdvcmljYWwucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/io/sas/sas\_constants.py](https://codecov.io/gh/pandas-dev/pandas/pull/24571/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXNfY29uc3RhbnRzLnB5) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/tseries/plotting.py](https://codecov.io/gh/pandas-dev/pandas/pull/24571/diff?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvcGxvdHRpbmcucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/tseries/converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/24571/diff?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvY29udmVydGVyLnB5) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/io/formats/html.py](https://codecov.io/gh/pandas-dev/pandas/pull/24571/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvaHRtbC5weQ==) | `0% <0%> (-99.04%)` | :arrow_down: |
| [pandas/core/groupby/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/24571/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9jYXRlZ29yaWNhbC5weQ==) | `0% <0%> (-95.46%)` | :arrow_down: |
| [pandas/io/sas/sas7bdat.py](https://codecov.io/gh/pandas-dev/pandas/pull/24571/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXM3YmRhdC5weQ==) | `0% <0%> (-91.17%)` | :arrow_down: |
| [pandas/io/sas/sas\_xport.py](https://codecov.io/gh/pandas-dev/pandas/pull/24571/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXNfeHBvcnQucHk=) | `0% <0%> (-90.15%)` | :arrow_down: |
| ... and [125 more](https://codecov.io/gh/pandas-dev/pandas/pull/24571/diff?src=pr&el=tree-more) | |

------

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

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24571?src=pr&el=h1) Report
> Merging [#24571](https://codecov.io/gh/pandas-dev/pandas/pull/24571?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/588b558cfa6b57c23e81202046b9f4add0e9e4f0?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/24571/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/24571?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #24571      +/-   ##
==========================================
+ Coverage   92.31%   92.31%   +<.01%     
==========================================
  Files         166      166              
  Lines       52556    52563       +7     
==========================================
+ Hits        48518    48526       +8     
+ Misses       4038     4037       -1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.74% <100%> (ø)` | :arrow_up: |
| #single | `43.06% <0%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24571?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/arrays/array\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/24571/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2FycmF5Xy5weQ==) | `100% <100%> (ø)` | :arrow_up: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/24571/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `87.71% <0%> (+0.09%)` | :arrow_up: |

------

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

lgtm. let's waiting on things though till we have fixed windows CI.
Can tm.to_array be replaced with pd.array then?
Replacing that turned up an issue with non-ns datetime64 / timedelta64
values. Pushing a fix for that in a bit.

On Wed, Jan 2, 2019 at 3:24 PM jbrockmendel <notifications@github.com>
wrote:

> Can tm.to_array be replaced with pd.array then?
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/24571#issuecomment-450989513>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABQHIoLf1SAvahB-3lBlaUcmz80qCt5Aks5u_SN2gaJpZM4ZnKb5>
> .
>

3d9cebe8b17d66a9425bb68431139be03188f5b3 fixes the datetime / timedelta
issue.

pd.array isn't a drop-in replacement for tm.to_array, since to_array
returns an ndarray for non-special cased dtypes.

On Wed, Jan 2, 2019 at 3:43 PM Tom Augspurger <tom.augspurger88@gmail.com>
wrote:

> Replacing that turned up an issue with non-ns datetime64 / timedelta64
> values. Pushing a fix for that in a bit.
>
> On Wed, Jan 2, 2019 at 3:24 PM jbrockmendel <notifications@github.com>
> wrote:
>
>> Can tm.to_array be replaced with pd.array then?
>>
>> —
>> You are receiving this because you authored the thread.
>> Reply to this email directly, view it on GitHub
>> <https://github.com/pandas-dev/pandas/pull/24571#issuecomment-450989513>,
>> or mute the thread
>> <https://github.com/notifications/unsubscribe-auth/ABQHIoLf1SAvahB-3lBlaUcmz80qCt5Aks5u_SN2gaJpZM4ZnKb5>
>> .
>>
>

@jbrockmendel but maybe should use its as much as possible (e.g. hit the special cases, else hit pd.array)
Agreed. I tried that briefly, and things failed (haven't looked deeply yet). Not sure if it's a bug in pd.array or different semantics for tm.to_array.
thanks @TomAugspurger