Skip to content

Commit 9305c36

Browse files
committed
COMPAT: Period(NaT) now returns pd.NaT
1 parent 20de266 commit 9305c36

File tree

8 files changed

+406
-302
lines changed

8 files changed

+406
-302
lines changed

doc/source/whatsnew/v0.19.0.txt

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

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

450489
Deprecations

0 commit comments

Comments
 (0)