Skip to content

Commit 980bffb

Browse files
jbrockmendelproost
authored andcommitted
DEPR: passing a dtype alias to DatetimeTZDtype(unit) (pandas-dev#29927)
1 parent 47e0a14 commit 980bffb

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

doc/source/whatsnew/v1.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
427427
- Removed the previously deprecated :meth:`MultiIndex.set_labels`, use :meth:`MultiIndex.set_codes` instead (:issue:`23752`)
428428
- Removed the previously deprecated "labels" keyword from :meth:`MultiIndex.set_codes`, :meth:`MultiIndex.copy`, :meth:`MultiIndex.drop`, use "codes" instead (:issue:`23752`)
429429
- Removed support for legacy HDF5 formats (:issue:`29787`)
430+
- Passing a dtype alias (e.g. 'datetime64[ns, UTC]') to :class:`DatetimeTZDtype` is no longer allowed, use :meth:`DatetimeTZDtype.construct_from_string` instead (:issue:`23990`)
430431
- :func:`read_excel` removed support for "skip_footer" argument, use "skipfooter" instead (:issue:`18836`)
431432
- :func:`read_excel` no longer allows an integer value for the parameter ``usecols``, instead pass a list of integers from 0 to ``usecols`` inclusive (:issue:`23635`)
432433
- :meth:`DataFrame.to_records` no longer supports the argument "convert_datetime64" (:issue:`18902`)

pandas/core/dtypes/dtypes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ def __init__(self, unit="ns", tz=None):
676676
"to DatetimeTZDtype is deprecated. Use "
677677
"'DatetimeTZDtype.construct_from_string()' instead."
678678
)
679-
warnings.warn(msg.format(tz=tz), FutureWarning, stacklevel=2)
679+
raise ValueError(msg)
680680
else:
681681
raise ValueError("DatetimeTZDtype only supports ns units")
682682

pandas/tests/dtypes/test_dtypes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def create(self):
187187

188188
def test_alias_to_unit_raises(self):
189189
# 23990
190-
with tm.assert_produces_warning(FutureWarning):
190+
with pytest.raises(ValueError, match="Passing a dtype alias"):
191191
DatetimeTZDtype("datetime64[ns, US/Central]")
192192

193193
def test_alias_to_unit_bad_alias_raises(self):

0 commit comments

Comments
 (0)