File tree 3 files changed +17
-2
lines changed
3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -150,6 +150,7 @@ Conversion
150
150
^^^^^^^^^^
151
151
- Bug in constructing :class: `Series ` with ``int64 `` dtype from a string list raising instead of casting (:issue: `44923 `)
152
152
- Bug in :meth: `DataFrame.eval ` incorrectly raising an ``AttributeError `` when there are negative values in function call (:issue: `46471 `)
153
+ - Bug where any :class: `ExtensionDtype ` subclass with ``kind="M" `` would be interpreted as a timezone type (:issue: `34986 `)
153
154
-
154
155
155
156
Strings
Original file line number Diff line number Diff line change @@ -382,9 +382,10 @@ def is_datetime64tz_dtype(arr_or_dtype) -> bool:
382
382
>>> is_datetime64tz_dtype(s)
383
383
True
384
384
"""
385
- if isinstance (arr_or_dtype , ExtensionDtype ):
385
+ if isinstance (arr_or_dtype , DatetimeTZDtype ):
386
386
# GH#33400 fastpath for dtype object
387
- return arr_or_dtype .kind == "M"
387
+ # GH 34986
388
+ return True
388
389
389
390
if arr_or_dtype is None :
390
391
return False
Original file line number Diff line number Diff line change 13
13
CategoricalDtype ,
14
14
CategoricalDtypeType ,
15
15
DatetimeTZDtype ,
16
+ ExtensionDtype ,
16
17
IntervalDtype ,
17
18
PeriodDtype ,
18
19
)
@@ -239,6 +240,18 @@ def test_is_datetime64tz_dtype():
239
240
assert com .is_datetime64tz_dtype (pd .DatetimeIndex (["2000" ], tz = "US/Eastern" ))
240
241
241
242
243
+ def test_custom_ea_kind_M_not_datetime64tz ():
244
+ # GH 34986
245
+ class NotTZDtype (ExtensionDtype ):
246
+ @property
247
+ def kind (self ) -> str :
248
+ return "M"
249
+
250
+ not_tz_dtype = NotTZDtype ()
251
+ assert not com .is_datetime64tz_dtype (not_tz_dtype )
252
+ assert not com .needs_i8_conversion (not_tz_dtype )
253
+
254
+
242
255
def test_is_timedelta64_dtype ():
243
256
assert not com .is_timedelta64_dtype (object )
244
257
assert not com .is_timedelta64_dtype (None )
You can’t perform that action at this time.
0 commit comments