You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Accessor object for datetimelike properties of the Series values.
Examples
--------
>>> s.dt.hour
>>> s.dt.second
>>> s.dt.quarter
Returns a Series indexed like the original Series.
Raises TypeError if the Series does not contain datetimelike values.
"""
defto_pydatetime(self):
returnself._get_values().to_pydatetime()
@property
deffreq(self):
returnself._get_values().inferred_freq
DatetimeProperties._add_delegate_accessors(
delegate=DatetimeIndex,
accessors=DatetimeIndex._datetimelike_ops,
typ='property')
DatetimeProperties._add_delegate_accessors(
delegate=DatetimeIndex,
accessors=DatetimeIndex._datetimelike_methods,
typ='method')
Is there any reason that we have it like that, while all others are just wrapped DatetimeIndex attributes/methods?
Because that means this returns (a bit strangly) an ndarray instead of a Series of the datetime.datetime values (making it inconsistent with other methods)
Ah, now I opened this issue, I thought of a probable reason: because otherwise the datetime.datetime values would quickly get inferred / coerced back to datetime64 ?
While reviewing: #20198, I notices this was defined in the
DatetimeProperties
itself:pandas/pandas/core/indexes/accessors.py
Lines 114 to 143 in 78ded25
Is there any reason that we have it like that, while all others are just wrapped DatetimeIndex attributes/methods?
Because that means this returns (a bit strangly) an ndarray instead of a Series of the datetime.datetime values (making it inconsistent with other methods)
cc @jbrockmendel @jreback
The text was updated successfully, but these errors were encountered: