@@ -777,8 +777,8 @@ def get_result(obj, window, min_periods=None, center=False):
777
777
series_result = get_result (series , window = win , min_periods = minp )
778
778
frame_result = get_result (frame , window = win , min_periods = minp )
779
779
else :
780
- series_result = get_result (series , window = win )
781
- frame_result = get_result (frame , window = win )
780
+ series_result = get_result (series , window = win , min_periods = 0 )
781
+ frame_result = get_result (frame , window = win , min_periods = 0 )
782
782
783
783
last_date = series_result .index [- 1 ]
784
784
prev_date = last_date - 24 * offsets .BDay ()
@@ -835,8 +835,8 @@ def get_result(obj, window, min_periods=None, center=False):
835
835
nan_mask = ~ nan_mask
836
836
tm .assert_almost_equal (result [nan_mask ], expected [nan_mask ])
837
837
else :
838
- result = get_result (self .series , len (self .series ) + 1 )
839
- expected = get_result (self .series , len (self .series ))
838
+ result = get_result (self .series , len (self .series ) + 1 , min_periods = 0 )
839
+ expected = get_result (self .series , len (self .series ), min_periods = 0 )
840
840
nan_mask = isna (result )
841
841
tm .assert_series_equal (nan_mask , isna (expected ))
842
842
@@ -851,10 +851,11 @@ def get_result(obj, window, min_periods=None, center=False):
851
851
pd .concat ([obj , Series ([np .NaN ] * 9 )]), 20 , min_periods = 15
852
852
)[9 :].reset_index (drop = True )
853
853
else :
854
- result = get_result (obj , 20 , center = True )
855
- expected = get_result (pd .concat ([obj , Series ([np .NaN ] * 9 )]), 20 )[
856
- 9 :
857
- ].reset_index (drop = True )
854
+ result = get_result (obj , 20 , min_periods = 0 , center = True )
855
+ print (result )
856
+ expected = get_result (
857
+ pd .concat ([obj , Series ([np .NaN ] * 9 )]), 20 , min_periods = 0
858
+ )[9 :].reset_index (drop = True )
858
859
859
860
tm .assert_series_equal (result , expected )
860
861
@@ -893,21 +894,27 @@ def get_result(obj, window, min_periods=None, center=False):
893
894
else :
894
895
series_xp = (
895
896
get_result (
896
- self .series .reindex (list (self .series .index ) + s ), window = 25
897
+ self .series .reindex (list (self .series .index ) + s ),
898
+ window = 25 ,
899
+ min_periods = 0 ,
897
900
)
898
901
.shift (- 12 )
899
902
.reindex (self .series .index )
900
903
)
901
904
frame_xp = (
902
905
get_result (
903
- self .frame .reindex (list (self .frame .index ) + s ), window = 25
906
+ self .frame .reindex (list (self .frame .index ) + s ),
907
+ window = 25 ,
908
+ min_periods = 0 ,
904
909
)
905
910
.shift (- 12 )
906
911
.reindex (self .frame .index )
907
912
)
908
913
909
- series_rs = get_result (self .series , window = 25 , center = True )
910
- frame_rs = get_result (self .frame , window = 25 , center = True )
914
+ series_rs = get_result (
915
+ self .series , window = 25 , min_periods = 0 , center = True
916
+ )
917
+ frame_rs = get_result (self .frame , window = 25 , min_periods = 0 , center = True )
911
918
912
919
if fill_value is not None :
913
920
series_xp = series_xp .fillna (fill_value )
@@ -964,7 +971,11 @@ def test_rolling_consistency(self, window, min_periods, center):
964
971
965
972
self ._test_moments_consistency_is_constant (
966
973
min_periods = min_periods ,
967
- count = lambda x : (x .rolling (window = window , center = center ).count ()),
974
+ count = lambda x : (
975
+ x .rolling (
976
+ window = window , min_periods = min_periods , center = center
977
+ ).count ()
978
+ ),
968
979
mean = lambda x : (
969
980
x .rolling (
970
981
window = window , min_periods = min_periods , center = center
@@ -989,19 +1000,26 @@ def test_rolling_consistency(self, window, min_periods, center):
989
1000
).var (ddof = 0 )
990
1001
),
991
1002
var_debiasing_factors = lambda x : (
992
- x .rolling (window = window , center = center )
1003
+ x .rolling (window = window , min_periods = min_periods , center = center )
993
1004
.count ()
994
1005
.divide (
995
- (x .rolling (window = window , center = center ).count () - 1.0 ).replace (
996
- 0.0 , np .nan
997
- )
1006
+ (
1007
+ x .rolling (
1008
+ window = window , min_periods = min_periods , center = center
1009
+ ).count ()
1010
+ - 1.0
1011
+ ).replace (0.0 , np .nan )
998
1012
)
999
1013
),
1000
1014
)
1001
1015
1002
1016
self ._test_moments_consistency (
1003
1017
min_periods = min_periods ,
1004
- count = lambda x : (x .rolling (window = window , center = center ).count ()),
1018
+ count = lambda x : (
1019
+ x .rolling (
1020
+ window = window , min_periods = min_periods , center = center
1021
+ ).count ()
1022
+ ),
1005
1023
mean = lambda x : (
1006
1024
x .rolling (
1007
1025
window = window , min_periods = min_periods , center = center
@@ -1071,7 +1089,7 @@ def test_rolling_consistency(self, window, min_periods, center):
1071
1089
if name == "count" :
1072
1090
rolling_f_result = rolling_f ()
1073
1091
rolling_apply_f_result = x .rolling (
1074
- window = window , min_periods = 0 , center = center
1092
+ window = window , min_periods = min_periods , center = center
1075
1093
).apply (func = f , raw = True )
1076
1094
else :
1077
1095
if name in ["cov" , "corr" ]:
0 commit comments