Skip to content

Commit b8dd114

Browse files
committed
make _from_selection a property
1 parent 10c7280 commit b8dd114

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

pandas/tseries/resample.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class Resampler(_GroupBy):
6464
'binner', 'grouper', 'groupby',
6565
'sort', 'kind', 'squeeze', 'keys',
6666
'group_keys', 'as_index', 'exclusions',
67-
'_groupby', '_from_selection']
67+
'_groupby']
6868

6969
# don't raise deprecation warning on attributes starting with these
7070
# patterns - prevents warnings caused by IPython introspection
@@ -85,14 +85,8 @@ def __init__(self, obj, groupby=None, axis=0, kind=None, **kwargs):
8585
self.exclusions = set()
8686
self.binner = None
8787
self.grouper = None
88-
self._from_selection = False
8988

9089
if self.groupby is not None:
91-
# upsampling and PeriodIndex resampling do not work
92-
# if resampling on a column or mi level
93-
# this state used to catch and raise an error
94-
self._from_selection = (self.groupby.key is not None or
95-
self.groupby.level is not None)
9690
self.groupby._set_grouper(self._convert_obj(obj), sort=True)
9791

9892
def __unicode__(self):
@@ -118,6 +112,15 @@ def _typ(self):
118112
return 'series'
119113
return 'dataframe'
120114

115+
@property
116+
def _from_selection(self):
117+
""" is the resampling from a DataFrame column or MultiIndex level """
118+
# upsampling and PeriodIndex resampling do not work
119+
# with selection, this state used to catch and raise an error
120+
return (self.groupby is not None and
121+
(self.groupby.key is not None or
122+
self.groupby.level is not None))
123+
121124
def _deprecated(self, op):
122125
warnings.warn(("\n.resample() is now a deferred operation\n"
123126
"You called {op}(...) on this deferred object "

0 commit comments

Comments
 (0)