Skip to content

Commit b66f617

Browse files
committed
Squashed commit of the following:
commit bccfc3f Merge: d65980e 9caf048 Author: Tom Augspurger <[email protected]> Date: Tue Oct 2 13:47:48 2018 -0500 Merge remote-tracking branch 'upstream/master' into period-dtype-type commit 9caf048 Author: Tom Augspurger <[email protected]> Date: Tue Oct 2 13:25:22 2018 -0500 CI: change windows vm image (pandas-dev#22948) commit d65980e Author: Tom Augspurger <[email protected]> Date: Tue Oct 2 11:46:38 2018 -0500 typo commit e5c61fc Merge: d7a8e1b 1d9f76c Author: Tom Augspurger <[email protected]> Date: Tue Oct 2 10:57:59 2018 -0500 Merge remote-tracking branch 'upstream/master' into period-dtype-type commit d7a8e1b Author: Tom Augspurger <[email protected]> Date: Tue Oct 2 10:57:56 2018 -0500 Fixed commit 598cc62 Author: Tom Augspurger <[email protected]> Date: Tue Oct 2 10:32:22 2018 -0500 doc note commit 83db05c Author: Tom Augspurger <[email protected]> Date: Tue Oct 2 10:28:52 2018 -0500 updates commit 1d9f76c Author: Joris Van den Bossche <[email protected]> Date: Tue Oct 2 17:11:11 2018 +0200 CLN: remove Index._to_embed (pandas-dev#22879) * CLN: remove Index._to_embed * pep8 commit 6247da0 Author: Tom Augspurger <[email protected]> Date: Tue Oct 2 08:50:41 2018 -0500 Provide default implementation for `data_repated` (pandas-dev#22935) commit f07ab80 Author: Tom Augspurger <[email protected]> Date: Tue Oct 2 06:22:27 2018 -0500 str, bytes commit 8a8bdb0 Author: Tom Augspurger <[email protected]> Date: Mon Oct 1 21:40:59 2018 -0500 import at top commit 99bafdd Author: Tom Augspurger <[email protected]> Date: Mon Oct 1 21:38:12 2018 -0500 Update type for PeriodDtype Removed unused IntervalDtypeType commit 5ce06b5 Author: Matthew Roeschke <[email protected]> Date: Mon Oct 1 14:22:20 2018 -0700 BUG: to_datetime preserves name of Index argument in the result (pandas-dev#22918) * BUG: to_datetime preserves name of Index argument in the result * correct test
1 parent 959cd72 commit b66f617

File tree

7 files changed

+24
-42
lines changed

7 files changed

+24
-42
lines changed

azure-pipelines.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ jobs:
1818
- template: ci/azure/windows.yml
1919
parameters:
2020
name: Windows
21-
vmImage: vs2017-win2017
21+
vmImage: vs2017-win2016
2222
- template: ci/azure/windows-py27.yml
2323
parameters:
2424
name: WindowsPy27
25-
vmImage: vs2017-win2017
25+
vmImage: vs2017-win2016

doc/source/whatsnew/v0.24.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@ ExtensionType Changes
505505
- :meth:`Series.astype` and :meth:`DataFrame.astype` now dispatch to :meth:`ExtensionArray.astype` (:issue:`21185:`).
506506
- Slicing a single row of a ``DataFrame`` with multiple ExtensionArrays of the same type now preserves the dtype, rather than coercing to object (:issue:`22784`)
507507
- Added :meth:`pandas.api.types.register_extension_dtype` to register an extension type with pandas (:issue:`22664`)
508+
- Updated the ``.type`` attribute for ``PeriodDtype``, ``DatetimeTZDtype``, and ``IntervalDtype`` to be instances of the dtype (``Period``, ``Timestamp``, and ``Interval`` respectively) (:issue:`22938`)
508509

509510
.. _whatsnew_0240.api.incompatibilities:
510511

pandas/core/dtypes/base.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ def type(self):
175175
"""The scalar type for the array, e.g. ``int``
176176
177177
It's expected ``ExtensionArray[item]`` returns an instance
178-
of ``ExtensionDtype.type`` for scalar ``item``.
178+
of ``ExtensionDtype.type`` for scalar ``item``, assuming
179+
that value is valid (not NA). NA values do not need to be
180+
instances of `type`.
179181
"""
180182
raise AbstractMethodError(self)
181183

pandas/core/dtypes/common.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
from pandas.compat import (string_types, text_type, binary_type,
55
PY3, PY36)
66
from pandas._libs import algos, lib
7-
from pandas._libs.tslibs import conversion, Period
7+
from pandas._libs.tslibs import conversion, Period, Timestamp
8+
from pandas._libs.interval import Interval
89

910
from pandas.core.dtypes.dtypes import (
1011
registry, CategoricalDtype, CategoricalDtypeType, DatetimeTZDtype,
11-
DatetimeTZDtypeType, PeriodDtype, IntervalDtype,
12-
IntervalDtypeType, PandasExtensionDtype, ExtensionDtype,
12+
PeriodDtype, IntervalDtype,
13+
PandasExtensionDtype, ExtensionDtype,
1314
_pandas_registry)
1415
from pandas.core.dtypes.generic import (
1516
ABCCategorical, ABCPeriodIndex, ABCDatetimeIndex, ABCSeries,
@@ -1903,20 +1904,20 @@ def _get_dtype_type(arr_or_dtype):
19031904
elif isinstance(arr_or_dtype, CategoricalDtype):
19041905
return CategoricalDtypeType
19051906
elif isinstance(arr_or_dtype, DatetimeTZDtype):
1906-
return DatetimeTZDtypeType
1907+
return Timestamp
19071908
elif isinstance(arr_or_dtype, IntervalDtype):
1908-
return IntervalDtypeType
1909+
return Interval
19091910
elif isinstance(arr_or_dtype, PeriodDtype):
1910-
return arr_or_dtype.type
1911+
return Period
19111912
elif isinstance(arr_or_dtype, string_types):
19121913
if is_categorical_dtype(arr_or_dtype):
19131914
return CategoricalDtypeType
19141915
elif is_datetime64tz_dtype(arr_or_dtype):
1915-
return DatetimeTZDtypeType
1916+
return Timestamp
19161917
elif is_period_dtype(arr_or_dtype):
19171918
return Period
19181919
elif is_interval_dtype(arr_or_dtype):
1919-
return IntervalDtypeType
1920+
return Interval
19201921
return _get_dtype_type(np.dtype(arr_or_dtype))
19211922
try:
19221923
return arr_or_dtype.dtype.type

pandas/core/dtypes/dtypes.py

+5-19
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import numpy as np
55
from pandas import compat
66
from pandas.core.dtypes.generic import ABCIndexClass, ABCCategoricalIndex
7-
from pandas._libs.tslibs import Period, NaT
7+
from pandas._libs.tslibs import Period, NaT, Timestamp
8+
from pandas._libs.interval import Interval
89

910
from .base import ExtensionDtype, _DtypeOpsMixin
1011

@@ -470,13 +471,6 @@ def _is_boolean(self):
470471
return is_bool_dtype(self.categories)
471472

472473

473-
class DatetimeTZDtypeType(type):
474-
"""
475-
the type of DatetimeTZDtype, this metaclass determines subclass ability
476-
"""
477-
pass
478-
479-
480474
class DatetimeTZDtype(PandasExtensionDtype):
481475

482476
"""
@@ -486,7 +480,7 @@ class DatetimeTZDtype(PandasExtensionDtype):
486480
THIS IS NOT A REAL NUMPY DTYPE, but essentially a sub-class of
487481
np.datetime64[ns]
488482
"""
489-
type = DatetimeTZDtypeType
483+
type = Timestamp
490484
kind = 'M'
491485
str = '|M8[ns]'
492486
num = 101
@@ -660,11 +654,11 @@ def construct_from_string(cls, string):
660654
raise TypeError("could not construct PeriodDtype")
661655

662656
def __unicode__(self):
663-
return self.name
657+
return compat.text_type(self.name)
664658

665659
@property
666660
def name(self):
667-
return u"period[{freq}]".format(freq=self.freq.freqstr)
661+
return str("period[{freq}]".format(freq=self.freq.freqstr))
668662

669663
@property
670664
def na_value(self):
@@ -709,13 +703,6 @@ def construct_array_type(cls):
709703
return PeriodArray
710704

711705

712-
class IntervalDtypeType(type):
713-
"""
714-
the type of IntervalDtype, this metaclass determines subclass ability
715-
"""
716-
pass
717-
718-
719706
@register_extension_dtype
720707
class IntervalDtype(PandasExtensionDtype, ExtensionDtype):
721708
"""
@@ -804,7 +791,6 @@ def construct_from_string(cls, string):
804791

805792
@property
806793
def type(self):
807-
from pandas import Interval
808794
return Interval
809795

810796
def __unicode__(self):

pandas/tests/dtypes/test_common.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -605,15 +605,15 @@ def test__get_dtype_fails(input_param):
605605
(pd.DatetimeIndex([1, 2]), np.datetime64),
606606
(pd.DatetimeIndex([1, 2]).dtype, np.datetime64),
607607
('<M8[ns]', np.datetime64),
608-
(pd.DatetimeIndex([1, 2], tz='Europe/London'), com.DatetimeTZDtypeType),
608+
(pd.DatetimeIndex([1, 2], tz='Europe/London'), pd.Timestamp),
609609
(pd.DatetimeIndex([1, 2], tz='Europe/London').dtype,
610-
com.DatetimeTZDtypeType),
611-
('datetime64[ns, Europe/London]', com.DatetimeTZDtypeType),
610+
pd.Timestamp),
611+
('datetime64[ns, Europe/London]', pd.Timestamp),
612612
(pd.SparseSeries([1, 2], dtype='int32'), np.int32),
613613
(pd.SparseSeries([1, 2], dtype='int32').dtype, np.int32),
614614
(PeriodDtype(freq='D'), pd.Period),
615615
('period[D]', pd.Period),
616-
(IntervalDtype(), com.IntervalDtypeType),
616+
(IntervalDtype(), pd.Interval),
617617
(None, type(None)),
618618
(1, type(None)),
619619
(1.2, type(None)),

pandas/tests/extension/conftest.py

-8
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@ def all_data(request, data, data_missing):
3232

3333
@pytest.fixture
3434
def data_repeated(data):
35-
<<<<<<< HEAD
36-
"""Return different versions of data for count times"""
37-
def gen(count):
38-
for _ in range(count):
39-
yield data
40-
yield gen
41-
=======
4235
"""
4336
Generate many datasets.
4437
@@ -56,7 +49,6 @@ def gen(count):
5649
for _ in range(count):
5750
yield data
5851
return gen
59-
>>>>>>> datetimelike-tshift
6052

6153

6254
@pytest.fixture

0 commit comments

Comments
 (0)