Skip to content

Commit 0a70b5f

Browse files
sinhrksjreback
authored andcommitted
API: Change Period('NAT') to return NaT
closes #12759 closes #13582 Author: sinhrks <[email protected]> Closes #13609 from sinhrks/period_nat and squashes the following commits: 9305c36 [sinhrks] COMPAT: Period(NaT) now returns pd.NaT
1 parent 71a0675 commit 0a70b5f

File tree

8 files changed

+407
-302
lines changed

8 files changed

+407
-302
lines changed

doc/source/whatsnew/v0.19.0.txt

+39
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,45 @@ Furthermore:
446446
- Passing duplicated ``percentiles`` will now raise a ``ValueError``.
447447
- Bug in ``.describe()`` on a DataFrame with a mixed-dtype column index, which would previously raise a ``TypeError`` (:issue:`13288`)
448448

449+
.. _whatsnew_0190.api.periodnat:
450+
451+
``Period('NaT')`` now returns ``pd.NaT``
452+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
453+
454+
Previously, ``Period`` has its own ``Period('NaT')`` representation different from ``pd.NaT``. Now ``Period('NaT')`` has been changed to return ``pd.NaT``. (:issue:`12759`, :issue:`13582`)
455+
456+
Previous Behavior:
457+
458+
.. code-block:: ipython
459+
460+
In [5]: pd.Period('NaT', freq='D')
461+
Out[5]: Period('NaT', 'D')
462+
463+
New Behavior:
464+
465+
.. ipython:: python
466+
467+
pd.Period('NaT')
468+
469+
470+
To be compat with ``Period`` addition and subtraction, ``pd.NaT`` now supports addition and subtraction with ``int``. Previously it raises ``ValueError``.
471+
472+
Previous Behavior:
473+
474+
.. code-block:: ipython
475+
476+
In [5]: pd.NaT + 1
477+
...
478+
ValueError: Cannot add integral value to Timestamp without freq.
479+
480+
New Behavior:
481+
482+
.. ipython:: python
483+
484+
pd.NaT + 1
485+
pd.NaT - 1
486+
487+
449488
.. _whatsnew_0190.deprecations:
450489

451490
Deprecations

0 commit comments

Comments
 (0)