Skip to content

Commit e0b7b77

Browse files
committed
Updates
* Use pandas_dtype * removed cache_readonly
1 parent ad2723c commit e0b7b77

File tree

5 files changed

+8
-10
lines changed

5 files changed

+8
-10
lines changed

pandas/core/arrays/datetimes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
timezones)
1313
import pandas.compat as compat
1414
from pandas.errors import PerformanceWarning
15-
from pandas.util._decorators import Appender, cache_readonly
15+
from pandas.util._decorators import Appender
1616

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

335-
@cache_readonly
335+
@property
336336
def dtype(self):
337337
if self.tz is None:
338338
return _NS_DTYPE

pandas/core/dtypes/dtypes.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
from pandas._libs.interval import Interval
88
from pandas._libs.tslibs import NaT, Period, Timestamp, timezones
9-
from pandas.util._decorators import cache_readonly
109

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

@@ -532,12 +531,12 @@ def __init__(self, unit="ns", tz=None):
532531
self._unit = unit
533532
self._tz = tz
534533

535-
@cache_readonly
534+
@property
536535
def unit(self):
537536
"""The precision of the datetime data."""
538537
return self._unit
539538

540-
@cache_readonly
539+
@property
541540
def tz(self):
542541
"""The timezone."""
543542
return self._tz

pandas/core/dtypes/missing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def _isna_ndarraylike(obj):
209209
vec = libmissing.isnaobj(values.ravel())
210210
result[...] = vec.reshape(shape)
211211

212-
elif needs_i8_conversion(obj):
212+
elif needs_i8_conversion(dtype):
213213
# this is the NaT pattern
214214
result = values.view('i8') == iNaT
215215
else:

pandas/core/internals/blocks.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2672,11 +2672,10 @@ def _astype(self, dtype, **kwargs):
26722672
these automatically copy, so copy=True has no effect
26732673
raise on an except if raise == True
26742674
"""
2675+
dtype = pandas_dtype(dtype)
26752676

26762677
# if we are passed a datetime64[ns, tz]
26772678
if is_datetime64tz_dtype(dtype):
2678-
dtype = DatetimeTZDtype(dtype)
2679-
26802679
values = self.values
26812680
if getattr(values, 'tz', None) is None:
26822681
values = DatetimeIndex(values).tz_localize('UTC')

pandas/tests/frame/test_dtypes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ def test_datetime_with_tz_dtypes(self):
9191
tzframe.iloc[1, 2] = pd.NaT
9292
result = tzframe.dtypes.sort_index()
9393
expected = Series([np.dtype('datetime64[ns]'),
94-
DatetimeTZDtype('datetime64[ns, US/Eastern]'),
95-
DatetimeTZDtype('datetime64[ns, CET]')],
94+
DatetimeTZDtype('ns', 'US/Eastern]'),
95+
DatetimeTZDtype('ns', 'CET')],
9696
['A', 'B', 'C'])
9797

9898
assert_series_equal(result, expected)

0 commit comments

Comments
 (0)