Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
* Use pandas_dtype
* removed cache_readonly
  • Loading branch information
TomAugspurger committed Nov 29, 2018
1 parent ad2723c commit e0b7b77
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
timezones)
import pandas.compat as compat
from pandas.errors import PerformanceWarning
from pandas.util._decorators import Appender, cache_readonly
from pandas.util._decorators import Appender

from pandas.core.dtypes.common import (
_NS_DTYPE, is_datetime64_dtype, is_datetime64tz_dtype, is_extension_type,
Expand Down Expand Up @@ -332,7 +332,7 @@ def _generate_range(cls, start, end, periods, freq, tz=None,
def _box_func(self):
return lambda x: Timestamp(x, freq=self.freq, tz=self.tz)

@cache_readonly
@property
def dtype(self):
if self.tz is None:
return _NS_DTYPE
Expand Down
5 changes: 2 additions & 3 deletions pandas/core/dtypes/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from pandas._libs.interval import Interval
from pandas._libs.tslibs import NaT, Period, Timestamp, timezones
from pandas.util._decorators import cache_readonly

from pandas.core.dtypes.generic import ABCCategoricalIndex, ABCIndexClass

Expand Down Expand Up @@ -532,12 +531,12 @@ def __init__(self, unit="ns", tz=None):
self._unit = unit
self._tz = tz

@cache_readonly
@property
def unit(self):
"""The precision of the datetime data."""
return self._unit

@cache_readonly
@property
def tz(self):
"""The timezone."""
return self._tz
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/dtypes/missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def _isna_ndarraylike(obj):
vec = libmissing.isnaobj(values.ravel())
result[...] = vec.reshape(shape)

elif needs_i8_conversion(obj):
elif needs_i8_conversion(dtype):
# this is the NaT pattern
result = values.view('i8') == iNaT
else:
Expand Down
3 changes: 1 addition & 2 deletions pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2672,11 +2672,10 @@ def _astype(self, dtype, **kwargs):
these automatically copy, so copy=True has no effect
raise on an except if raise == True
"""
dtype = pandas_dtype(dtype)

# if we are passed a datetime64[ns, tz]
if is_datetime64tz_dtype(dtype):
dtype = DatetimeTZDtype(dtype)

values = self.values
if getattr(values, 'tz', None) is None:
values = DatetimeIndex(values).tz_localize('UTC')
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/frame/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ def test_datetime_with_tz_dtypes(self):
tzframe.iloc[1, 2] = pd.NaT
result = tzframe.dtypes.sort_index()
expected = Series([np.dtype('datetime64[ns]'),
DatetimeTZDtype('datetime64[ns, US/Eastern]'),
DatetimeTZDtype('datetime64[ns, CET]')],
DatetimeTZDtype('ns', 'US/Eastern]'),
DatetimeTZDtype('ns', 'CET')],
['A', 'B', 'C'])

assert_series_equal(result, expected)
Expand Down

0 comments on commit e0b7b77

Please sign in to comment.