Skip to content

Commit a293d22

Browse files
atbdjreback
authored andcommitted
COMPAT: NaT support tz_localize / tz_convert (#15830) (#15868)
1 parent 74f527f commit a293d22

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

doc/source/whatsnew/v0.20.0.txt

+2
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,8 @@ Other API Changes
837837
ignored (no longer needed to specify the new behaviour) and is deprecated.
838838
- ``NaT`` will now correctly report ``False`` for datetimelike boolean operations such as ``is_month_start`` (:issue:`15781`)
839839
- ``NaT`` will now correctly return ``np.nan`` for ``Timedelta`` and ``Period`` accessors such as ``days`` and ``quarter`` (:issue:`15782`)
840+
- ``NaT`` will now returns ``NaT`` for ``tz_localize`` and ``tz_convert``
841+
methods (:issue:`15830`)
840842

841843
.. _whatsnew_0200.deprecations:
842844

pandas/_libs/tslib.pyx

+2-1
Original file line numberDiff line numberDiff line change
@@ -3835,7 +3835,8 @@ for field in fields:
38353835
# to the NaTType class; these can return NaT, np.nan
38363836
# or raise respectively
38373837
_nat_methods = ['date', 'now', 'replace', 'to_pydatetime',
3838-
'today', 'round', 'floor', 'ceil']
3838+
'today', 'round', 'floor', 'ceil', 'tz_convert',
3839+
'tz_localize']
38393840
_nan_methods = ['weekday', 'isoweekday', 'total_seconds']
38403841
_implemented_methods = ['to_datetime', 'to_datetime64', 'isoformat']
38413842
_implemented_methods.extend(_nat_methods)

pandas/tests/scalar/test_nat.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ def test_NaT_methods():
129129
'timetuple', 'timetz', 'toordinal', 'tzname',
130130
'utcfromtimestamp', 'utcnow', 'utcoffset',
131131
'utctimetuple']
132-
nat_methods = ['date', 'now', 'replace', 'to_datetime', 'today']
132+
nat_methods = ['date', 'now', 'replace', 'to_datetime', 'today',
133+
'tz_convert', 'tz_localize']
133134
nan_methods = ['weekday', 'isoweekday']
134135

135136
for method in raise_methods:

0 commit comments

Comments
 (0)