Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit bccfc3f
Merge: d65980e 9caf048
Author: Tom Augspurger <tom.w.augspurger@gmail.com>
Date:   Tue Oct 2 13:47:48 2018 -0500

    Merge remote-tracking branch 'upstream/master' into period-dtype-type

commit 9caf048
Author: Tom Augspurger <TomAugspurger@users.noreply.github.com>
Date:   Tue Oct 2 13:25:22 2018 -0500

    CI: change windows vm image (pandas-dev#22948)

commit d65980e
Author: Tom Augspurger <tom.w.augspurger@gmail.com>
Date:   Tue Oct 2 11:46:38 2018 -0500

    typo

commit e5c61fc
Merge: d7a8e1b 1d9f76c
Author: Tom Augspurger <tom.w.augspurger@gmail.com>
Date:   Tue Oct 2 10:57:59 2018 -0500

    Merge remote-tracking branch 'upstream/master' into period-dtype-type

commit d7a8e1b
Author: Tom Augspurger <tom.w.augspurger@gmail.com>
Date:   Tue Oct 2 10:57:56 2018 -0500

    Fixed

commit 598cc62
Author: Tom Augspurger <tom.w.augspurger@gmail.com>
Date:   Tue Oct 2 10:32:22 2018 -0500

    doc note

commit 83db05c
Author: Tom Augspurger <tom.w.augspurger@gmail.com>
Date:   Tue Oct 2 10:28:52 2018 -0500

    updates

commit 1d9f76c
Author: Joris Van den Bossche <jorisvandenbossche@gmail.com>
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 <TomAugspurger@users.noreply.github.com>
Date:   Tue Oct 2 08:50:41 2018 -0500

    Provide default implementation for `data_repated` (pandas-dev#22935)

commit f07ab80
Author: Tom Augspurger <tom.w.augspurger@gmail.com>
Date:   Tue Oct 2 06:22:27 2018 -0500

    str, bytes

commit 8a8bdb0
Author: Tom Augspurger <tom.w.augspurger@gmail.com>
Date:   Mon Oct 1 21:40:59 2018 -0500

    import at top

commit 99bafdd
Author: Tom Augspurger <tom.w.augspurger@gmail.com>
Date:   Mon Oct 1 21:38:12 2018 -0500

    Update type for PeriodDtype

    Removed unused IntervalDtypeType

commit 5ce06b5
Author: Matthew Roeschke <emailformattr@gmail.com>
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
  • Loading branch information
TomAugspurger committed Oct 2, 2018
1 parent 959cd72 commit b66f617
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 42 deletions.
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
- template: ci/azure/windows.yml
parameters:
name: Windows
vmImage: vs2017-win2017
vmImage: vs2017-win2016
- template: ci/azure/windows-py27.yml
parameters:
name: WindowsPy27
vmImage: vs2017-win2017
vmImage: vs2017-win2016
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.24.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ ExtensionType Changes
- :meth:`Series.astype` and :meth:`DataFrame.astype` now dispatch to :meth:`ExtensionArray.astype` (:issue:`21185:`).
- 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`)
- Added :meth:`pandas.api.types.register_extension_dtype` to register an extension type with pandas (:issue:`22664`)
- Updated the ``.type`` attribute for ``PeriodDtype``, ``DatetimeTZDtype``, and ``IntervalDtype`` to be instances of the dtype (``Period``, ``Timestamp``, and ``Interval`` respectively) (:issue:`22938`)

.. _whatsnew_0240.api.incompatibilities:

Expand Down
4 changes: 3 additions & 1 deletion pandas/core/dtypes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
17 changes: 9 additions & 8 deletions pandas/core/dtypes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
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 (
registry, CategoricalDtype, CategoricalDtypeType, DatetimeTZDtype,
DatetimeTZDtypeType, PeriodDtype, IntervalDtype,
IntervalDtypeType, PandasExtensionDtype, ExtensionDtype,
PeriodDtype, IntervalDtype,
PandasExtensionDtype, ExtensionDtype,
_pandas_registry)
from pandas.core.dtypes.generic import (
ABCCategorical, ABCPeriodIndex, ABCDatetimeIndex, ABCSeries,
Expand Down Expand Up @@ -1903,20 +1904,20 @@ def _get_dtype_type(arr_or_dtype):
elif isinstance(arr_or_dtype, CategoricalDtype):
return CategoricalDtypeType
elif isinstance(arr_or_dtype, DatetimeTZDtype):
return DatetimeTZDtypeType
return Timestamp
elif isinstance(arr_or_dtype, IntervalDtype):
return IntervalDtypeType
return Interval
elif isinstance(arr_or_dtype, PeriodDtype):
return arr_or_dtype.type
return Period
elif isinstance(arr_or_dtype, string_types):
if is_categorical_dtype(arr_or_dtype):
return CategoricalDtypeType
elif is_datetime64tz_dtype(arr_or_dtype):
return DatetimeTZDtypeType
return Timestamp
elif is_period_dtype(arr_or_dtype):
return Period
elif is_interval_dtype(arr_or_dtype):
return IntervalDtypeType
return Interval
return _get_dtype_type(np.dtype(arr_or_dtype))
try:
return arr_or_dtype.dtype.type
Expand Down
24 changes: 5 additions & 19 deletions pandas/core/dtypes/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
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

Expand Down Expand Up @@ -470,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):

"""
Expand All @@ -486,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
Expand Down Expand Up @@ -660,11 +654,11 @@ def construct_from_string(cls, string):
raise TypeError("could not construct PeriodDtype")

def __unicode__(self):
return self.name
return compat.text_type(self.name)

@property
def name(self):
return u"period[{freq}]".format(freq=self.freq.freqstr)
return str("period[{freq}]".format(freq=self.freq.freqstr))

@property
def na_value(self):
Expand Down Expand Up @@ -709,13 +703,6 @@ def construct_array_type(cls):
return PeriodArray


class IntervalDtypeType(type):
"""
the type of IntervalDtype, this metaclass determines subclass ability
"""
pass


@register_extension_dtype
class IntervalDtype(PandasExtensionDtype, ExtensionDtype):
"""
Expand Down Expand Up @@ -804,7 +791,6 @@ def construct_from_string(cls, string):

@property
def type(self):
from pandas import Interval
return Interval

def __unicode__(self):
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/dtypes/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,15 +605,15 @@ def test__get_dtype_fails(input_param):
(pd.DatetimeIndex([1, 2]), np.datetime64),
(pd.DatetimeIndex([1, 2]).dtype, np.datetime64),
('<M8[ns]', np.datetime64),
(pd.DatetimeIndex([1, 2], tz='Europe/London'), com.DatetimeTZDtypeType),
(pd.DatetimeIndex([1, 2], tz='Europe/London'), pd.Timestamp),
(pd.DatetimeIndex([1, 2], tz='Europe/London').dtype,
com.DatetimeTZDtypeType),
('datetime64[ns, Europe/London]', com.DatetimeTZDtypeType),
pd.Timestamp),
('datetime64[ns, Europe/London]', pd.Timestamp),
(pd.SparseSeries([1, 2], dtype='int32'), np.int32),
(pd.SparseSeries([1, 2], dtype='int32').dtype, np.int32),
(PeriodDtype(freq='D'), pd.Period),
('period[D]', pd.Period),
(IntervalDtype(), com.IntervalDtypeType),
(IntervalDtype(), pd.Interval),
(None, type(None)),
(1, type(None)),
(1.2, type(None)),
Expand Down
8 changes: 0 additions & 8 deletions pandas/tests/extension/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ def all_data(request, data, data_missing):

@pytest.fixture
def data_repeated(data):
<<<<<<< HEAD
"""Return different versions of data for count times"""
def gen(count):
for _ in range(count):
yield data
yield gen
=======
"""
Generate many datasets.
Expand All @@ -56,7 +49,6 @@ def gen(count):
for _ in range(count):
yield data
return gen
>>>>>>> datetimelike-tshift


@pytest.fixture
Expand Down

0 comments on commit b66f617

Please sign in to comment.