From 83db05c7ddec7a87ff77430ab686873b8a329a0f Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Tue, 2 Oct 2018 10:28:52 -0500 Subject: [PATCH] updates --- pandas/core/dtypes/base.py | 4 +++- pandas/core/dtypes/common.py | 4 ++-- pandas/core/dtypes/dtypes.py | 11 ++--------- pandas/tests/dtypes/test_common.py | 6 +++--- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/pandas/core/dtypes/base.py b/pandas/core/dtypes/base.py index a552251ebbafa..5c9ba921226c0 100644 --- a/pandas/core/dtypes/base.py +++ b/pandas/core/dtypes/base.py @@ -175,7 +175,9 @@ def type(self): """The scalar type for the array, e.g. ``int`` It's expected ``ExtensionArray[item]`` returns an instance - of ``ExtensionDtype.type`` for scalar ``item``. + of ``ExtensionDtype.type`` for scalar ``item``, assuming + that value is valid (not NA). NA values do not need to be + instances of `type`. """ raise AbstractMethodError(self) diff --git a/pandas/core/dtypes/common.py b/pandas/core/dtypes/common.py index a3b61e2e1191e..cfa25d04a3201 100644 --- a/pandas/core/dtypes/common.py +++ b/pandas/core/dtypes/common.py @@ -4,7 +4,7 @@ from pandas.compat import (string_types, text_type, binary_type, PY3, PY36) from pandas._libs import algos, lib -from pandas._libs.tslibs import conversion, Period +from pandas._libs.tslibs import conversion, Period, Timestamp from pandas._libs.interval import Interval from pandas.core.dtypes.dtypes import ( @@ -1915,7 +1915,7 @@ def _get_dtype_type(arr_or_dtype): if is_categorical_dtype(arr_or_dtype): return CategoricalDtypeType elif is_datetime64tz_dtype(arr_or_dtype): - return DatetimeTZDtypeType + return Timestmap elif is_period_dtype(arr_or_dtype): return Period elif is_interval_dtype(arr_or_dtype): diff --git a/pandas/core/dtypes/dtypes.py b/pandas/core/dtypes/dtypes.py index 0403b3fb28847..944365232db65 100644 --- a/pandas/core/dtypes/dtypes.py +++ b/pandas/core/dtypes/dtypes.py @@ -4,7 +4,7 @@ import numpy as np from pandas import compat from pandas.core.dtypes.generic import ABCIndexClass, ABCCategoricalIndex -from pandas._libs.tslibs import Period, NaT +from pandas._libs.tslibs import Period, NaT, Timestamp from pandas._libs.interval import Interval from .base import ExtensionDtype, _DtypeOpsMixin @@ -471,13 +471,6 @@ def _is_boolean(self): return is_bool_dtype(self.categories) -class DatetimeTZDtypeType(type): - """ - the type of DatetimeTZDtype, this metaclass determines subclass ability - """ - pass - - class DatetimeTZDtype(PandasExtensionDtype): """ @@ -487,7 +480,7 @@ class DatetimeTZDtype(PandasExtensionDtype): THIS IS NOT A REAL NUMPY DTYPE, but essentially a sub-class of np.datetime64[ns] """ - type = DatetimeTZDtypeType + type = Timestamp kind = 'M' str = '|M8[ns]' num = 101 diff --git a/pandas/tests/dtypes/test_common.py b/pandas/tests/dtypes/test_common.py index b63498991dabc..e5cb650440b91 100644 --- a/pandas/tests/dtypes/test_common.py +++ b/pandas/tests/dtypes/test_common.py @@ -605,10 +605,10 @@ def test__get_dtype_fails(input_param): (pd.DatetimeIndex([1, 2]), np.datetime64), (pd.DatetimeIndex([1, 2]).dtype, np.datetime64), ('