File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -694,6 +694,20 @@ def test_resample_timestamp_to_period(simple_date_range_series):
694
694
tm .assert_series_equal (result , expected )
695
695
696
696
697
+ def test_datetime_resample_sum_min_count ():
698
+ # GH 19974
699
+ index = date_range (start = "2018" , freq = "M" , periods = 6 )
700
+ data = np .ones (6 )
701
+ data [3 :6 ] = np .nan
702
+ datetime = Series (data , index )
703
+ result = datetime .resample ("Q" ).sum (min_count = 1 )
704
+
705
+ index = date_range ("2018-03-31" , "2018-06-30" , freq = "Q-DEC" )
706
+ expected = Series ([3 , np .nan ], index )
707
+
708
+ tm .assert_series_equal (result , expected )
709
+
710
+
697
711
def test_ohlc_5min ():
698
712
def _ohlc (group ):
699
713
if isna (group ).all ():
Original file line number Diff line number Diff line change @@ -548,6 +548,19 @@ def test_quarterly_resampling(self):
548
548
exp = ts .to_timestamp ().resample ("A" ).mean ().to_period ()
549
549
tm .assert_series_equal (result , exp )
550
550
551
+ def test_period_resample_sum_min_count (self ):
552
+ # GH 19974
553
+ index = date_range (start = "2018" , freq = "M" , periods = 6 )
554
+ data = np .ones (6 )
555
+ data [3 :6 ] = np .nan
556
+ period = Series (data , index ).to_period ()
557
+ result = period .resample ("Q" ).sum (min_count = 1 )
558
+
559
+ index = PeriodIndex (["2018Q1" , "2018Q2" ], freq = "Q-DEC" )
560
+ expected = Series ([3 , np .nan ], index )
561
+
562
+ tm .assert_series_equal (result , expected )
563
+
551
564
def test_resample_weekly_bug_1726 (self ):
552
565
# 8/6/12 is a Monday
553
566
ind = date_range (start = "8/6/2012" , end = "8/26/2012" , freq = "D" )
You can’t perform that action at this time.
0 commit comments