ENH: let .dt.isocalendar() return float64 in presence of NaT #54657
Labels
Datetime
Datetime data dtype
Dtype Conversions
Unexpected or buggy dtype conversions
Enhancement
Needs Discussion
Requires discussion from core team before further action
Feature Type
Adding new functionality to pandas
Changing existing functionality in pandas
Removing existing functionality in pandas
Problem Description
Currently
.dt.isocalendar()
returnsUInt32
withpd.NA
in presence ofNaT
, whereas.dt.year
returnsfloat64
withnp.nan
. We've encountered this discrepancy over at xarray pydata/xarray#7928.We could align that at the respective xarray accessor, but it would make more sense to align it here.
Feature Description
One solution would be to use the same functionality present in
_field_accessor
(maybe_mask_results
) to do the conversion tofloat64
in presence ofNaT
. Please have a look at the below code.I can move this into a Pull Request, if there is interest. I'll also try to implemented some workaround in xarray until a final solution has settled.
Alternative Solutions
No alternative solutions considered.
Additional Context
No response
The text was updated successfully, but these errors were encountered: