Skip to content

Commit 2a80837

Browse files
committed
COMPAT: disable Series datetimeindex/periodindex methods introduced in (GH6380)
1 parent ccd593f commit 2a80837

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

pandas/core/base.py

-2
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,10 @@ def _wrap_access_object(self, obj):
261261

262262
def max(self):
263263
""" The maximum value of the object """
264-
self._is_allowed_index_op('max')
265264
return self.values.max()
266265

267266
def min(self):
268267
""" The minimum value of the object """
269-
self._is_allowed_index_op('min')
270268
return self.values.min()
271269

272270
def value_counts(self, normalize=False, sort=True, ascending=False,

pandas/core/series.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,15 @@ class Series(base.IndexOpsMixin, generic.NDFrame):
121121

122122
@property
123123
def _allow_datetime_index_ops(self):
124-
return self.index.is_all_dates and isinstance(self.index, DatetimeIndex)
124+
# disabling to invalidate datetime index ops
125+
# return self.index.is_all_dates and isinstance(self.index, DatetimeIndex)
126+
return False
125127

126128
@property
127129
def _allow_period_index_ops(self):
128-
return self.index.is_all_dates and isinstance(self.index, PeriodIndex)
130+
# disabling to invalidate period index ops
131+
# return self.index.is_all_dates and isinstance(self.index, PeriodIndex)
132+
return False
129133

130134
def __init__(self, data=None, index=None, dtype=None, name=None,
131135
copy=False, fastpath=False):

pandas/tests/test_base.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,14 @@ def setUp(self):
452452

453453
def test_ops_properties(self):
454454
self.check_ops_properties(['year','month','day','hour','minute','second','weekofyear','week','dayofweek','dayofyear','quarter'])
455-
self.check_ops_properties(['date','time','microsecond','nanosecond', 'is_month_start', 'is_month_end', 'is_quarter_start', 'is_quarter_end', 'is_year_start', 'is_year_end'], lambda x: isinstance(x,DatetimeIndex))
455+
self.check_ops_properties(['date','time','microsecond','nanosecond', 'is_month_start', 'is_month_end', 'is_quarter_start',
456+
'is_quarter_end', 'is_year_start', 'is_year_end'], lambda x: isinstance(x,DatetimeIndex))
457+
458+
def test_ops_properties_basic(self):
459+
460+
# sanity check that the behavior didn't change
461+
for op in ['year','day','second','weekday']:
462+
self.assertRaises(TypeError, lambda x: getattr(self.dt_series,op))
456463

457464
class TestPeriodIndexOps(Ops):
458465
_allowed = '_allow_period_index_ops'

pandas/tests/test_series.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -5619,7 +5619,9 @@ def test_asfreq(self):
56195619

56205620
def test_weekday(self):
56215621
# Just run the function
5622-
weekdays = self.ts.weekday
5622+
def f():
5623+
self.ts.weekday
5624+
self.assertRaises(TypeError, f)
56235625

56245626
def test_diff(self):
56255627
# Just run the function
@@ -5715,7 +5717,7 @@ def test_select(self):
57155717
assert_series_equal(result, expected)
57165718

57175719
result = self.ts.select(lambda x: x.weekday() == 2)
5718-
expected = self.ts[self.ts.weekday == 2]
5720+
expected = self.ts[self.ts.index.weekday == 2]
57195721
assert_series_equal(result, expected)
57205722

57215723
#------------------------------------------------------------------------------

0 commit comments

Comments
 (0)