Skip to content

Commit 23fd9bb

Browse files
committed
fixup
1 parent 8cb7d9e commit 23fd9bb

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

pandas/core/base.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
from pandas.core.dtypes.common import (
1818
is_datetime64tz_dtype, is_datetimelike, is_extension_array_dtype,
1919
is_extension_type, is_list_like, is_object_dtype, is_scalar)
20-
from pandas.core.dtypes.generic import ABCDataFrame, ABCIndexClass, ABCSeries
20+
from pandas.core.dtypes.generic import (
21+
ABCDataFrame, ABCDatetimeArray, ABCIndexClass, ABCSeries)
2122
from pandas.core.dtypes.missing import isna
2223

2324
from pandas.core import algorithms, common as com
@@ -849,9 +850,13 @@ def array(self):
849850
"""
850851
result = self._values
851852

852-
# TODO(DatetimeArray): remvoe the second clause.
853-
if (not is_extension_array_dtype(result.dtype)
854-
and not is_datetime64tz_dtype(result.dtype)):
853+
if not (is_extension_array_dtype(result.dtype)
854+
or isinstance(result, ABCDatetimeArray)):
855+
# TODO: Should this be a DatetimeArray or PandasArray
856+
# for tz-naive data?
857+
# DatetimeArray is a bit strange, since tz-naive
858+
# arrays are an ExtensionArray, but the dtype is not
859+
# an extension dtype.
855860
from pandas.core.arrays.numpy_ import PandasArray
856861

857862
result = PandasArray(result)

pandas/tests/arrays/test_datetimes.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ def test_mismatched_timezone_raises(self):
2020
arr = DatetimeArray(np.array(['2000-01-01T06:00:00'], dtype='M8[ns]'),
2121
dtype=DatetimeTZDtype(tz='US/Central'))
2222
dtype = DatetimeTZDtype(tz='US/Eastern')
23-
with pytest.raises(TypeError, match='data is already tz-aware'):
23+
# TODO: figure out error message
24+
with pytest.raises(TypeError, match='Timezone of the array'):
2425
DatetimeArray(arr, dtype=dtype)
2526

2627
def test_non_array_raises(self):

0 commit comments

Comments
 (0)