@@ -801,6 +801,13 @@ def _get_binner_for_time(self):
801
801
def _convert_obj (self , obj ):
802
802
obj = super (PeriodIndexResampler , self )._convert_obj (obj )
803
803
804
+ if self ._from_selection :
805
+ # see GH 14008, GH 12871
806
+ msg = ("Resampling from level= or on= selection"
807
+ " with a PeriodIndex is not currently supported,"
808
+ " use .set_index(...) to explicitly set index" )
809
+ raise NotImplementedError (msg )
810
+
804
811
offset = to_offset (self .freq )
805
812
if offset .n > 1 :
806
813
if self .kind == 'period' : # pragma: no cover
@@ -811,14 +818,7 @@ def _convert_obj(self, obj):
811
818
812
819
# convert to timestamp
813
820
if not (self .kind is None or self .kind == 'period' ):
814
- if self ._from_selection :
815
- # see GH 14008, GH 12871
816
- msg = ("Resampling from level= or on= selection"
817
- " with a PeriodIndex is not currently supported,"
818
- " use .set_index(...) to explicitly set index" )
819
- raise NotImplementedError (msg )
820
- else :
821
- obj = obj .to_timestamp (how = self .convention )
821
+ obj = obj .to_timestamp (how = self .convention )
822
822
823
823
return obj
824
824
@@ -865,11 +865,7 @@ def _upsample(self, method, limit=None, fill_value=None):
865
865
.fillna
866
866
867
867
"""
868
- if self ._from_selection :
869
- raise ValueError ("Upsampling from level= or on= selection"
870
- " is not supported, use .set_index(...)"
871
- " to explicitly set index to"
872
- " datetime-like" )
868
+
873
869
# we may need to actually resample as if we are timestamps
874
870
if self .kind == 'timestamp' :
875
871
return super (PeriodIndexResampler , self )._upsample (
0 commit comments