@@ -842,6 +842,13 @@ def _get_binner_for_time(self):
842
842
def _convert_obj (self , obj ):
843
843
obj = super (PeriodIndexResampler , self )._convert_obj (obj )
844
844
845
+ if self ._from_selection :
846
+ # see GH 14008, GH 12871
847
+ msg = ("Resampling from level= or on= selection"
848
+ " with a PeriodIndex is not currently supported,"
849
+ " use .set_index(...) to explicitly set index" )
850
+ raise NotImplementedError (msg )
851
+
845
852
offset = to_offset (self .freq )
846
853
if offset .n > 1 :
847
854
if self .kind == 'period' : # pragma: no cover
@@ -852,14 +859,7 @@ def _convert_obj(self, obj):
852
859
853
860
# convert to timestamp
854
861
if not (self .kind is None or self .kind == 'period' ):
855
- if self ._from_selection :
856
- # see GH 14008, GH 12871
857
- msg = ("Resampling from level= or on= selection"
858
- " with a PeriodIndex is not currently supported,"
859
- " use .set_index(...) to explicitly set index" )
860
- raise NotImplementedError (msg )
861
- else :
862
- obj = obj .to_timestamp (how = self .convention )
862
+ obj = obj .to_timestamp (how = self .convention )
863
863
864
864
return obj
865
865
@@ -906,11 +906,7 @@ def _upsample(self, method, limit=None, fill_value=None):
906
906
.fillna
907
907
908
908
"""
909
- if self ._from_selection :
910
- raise ValueError ("Upsampling from level= or on= selection"
911
- " is not supported, use .set_index(...)"
912
- " to explicitly set index to"
913
- " datetime-like" )
909
+
914
910
# we may need to actually resample as if we are timestamps
915
911
if self .kind == 'timestamp' :
916
912
return super (PeriodIndexResampler , self )._upsample (
0 commit comments