@@ -2847,6 +2847,29 @@ def test_loffset_returns_datetimeindex(self):
2847
2847
assert_frame_equal (result_agg , expected )
2848
2848
assert_frame_equal (result_how , expected )
2849
2849
2850
+ def test_upsampling_ohlc (self ):
2851
+ # GH 13083
2852
+ pi = PeriodIndex (start = '2000' , freq = 'D' , periods = 10 )
2853
+ s = Series (range (len (pi )), index = pi )
2854
+ expected = s .to_timestamp ().resample ('H' ).ohlc ().to_period ()
2855
+ # timestamp-based resampling doesn't include all sub-periods
2856
+ # of the last original period, so extend accordingly:
2857
+ pi_ext = PeriodIndex (start = '2000' , freq = 'H' , periods = 24 * len (pi ))
2858
+ expected = expected .reindex (pi_ext )
2859
+ result = s .resample ('H' ).ohlc ()
2860
+ assert_frame_equal (result , expected )
2861
+
2862
+ def test_upsampling_ohlc_freq_multiples (self ):
2863
+ pi = PeriodIndex (start = '2000' , freq = 'D' , periods = 10 )
2864
+ s = pd .Series (range (len (pi )), index = pi )
2865
+ expected = s .to_timestamp ().resample ('12H' ).ohlc ().to_period ('12H' )
2866
+ # timestamp-based resampling doesn't include all sub-periods
2867
+ # of the last original period, so extend accordingly:
2868
+ pi_ext = PeriodIndex (start = '2000' , freq = '12H' , periods = 2 * len (pi ))
2869
+ expected = expected .reindex (pi_ext )
2870
+ result = s .resample ('12H' , kind = 'period' ).ohlc ()
2871
+ assert_frame_equal (result , expected )
2872
+
2850
2873
2851
2874
class TestTimedeltaIndex (Base , tm .TestCase ):
2852
2875
_index_factory = lambda x : timedelta_range
0 commit comments