-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Constructing a DatetimeArray with pd.array? #24656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hmm, I see that passing datetime / Timestamp objects, then it is inferred to return a DatetimeArray:
(but that's not the most convenient way to quickly create such an array) Also passing a datetime64[ns] numpy array gives a DatetimeArray:
but when specifying that dtype inside Reading the docstring of |
Agreed, both of those feel strange. The DTI one is probably an outright buggy. The |
Yes, I would be +1 on that. |
Indeed. Returning a tz-naive DatetimeArray or a TimedeltaArray wouldn't
pass a type checker because of their dtype.
But this is the same tradeoff as Series[tz-navie].array, where we returned
a DatetimeArray.
…On Mon, Jan 7, 2019 at 6:44 AM Joris Van den Bossche < ***@***.***> wrote:
but we might want to consider overriding NumPy when we have arrays that
share string aliases with NumPy (I think just datetime64[ns] and
timedelta64[ns]).
Yes, I would be +1 on that.
It somehow complicates the "rules", but it is also very strange that
pd.array does not give the Array type that pandas actually uses under the
hood for those dtypes.
(this signals a bit the problems of clashing dtypes / the fact that
DatetimeArray still has a numpy dtype)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#24656 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABQHIio3FmQehgjaZueCVXU0hEF7gU7Hks5vA0EkgaJpZM4ZyucK>
.
|
* API: Datetime/TimedeltaArray from to_datetime Closes #24656
* API: Datetime/TimedeltaArray from to_datetime Closes pandas-dev#24656
* API: Datetime/TimedeltaArray from to_datetime Closes pandas-dev#24656
I wanted to create a naive
DatetimeArray
withpd.array
, but that doesn't seem very easy or even impossible:Specyfing
dtype='datetime64[ns]'
gives a numpy backed PandasArray:We also can't specify a custom dtype, as it needs a tz:
Passing a DatetimeIndex also gives a PandasArray:
Should one of those give a DatetimeArray instead of PandasArray?
The text was updated successfully, but these errors were encountered: