@@ -207,6 +207,20 @@ def f():
207
207
'A' , 'ra' , 'std' ), ('B' , 'rb' , 'mean' ), ('B' , 'rb' , 'std' )])
208
208
tm .assert_frame_equal (result , expected , check_like = True )
209
209
210
+ def test_count_nonnumeric_types (self ):
211
+ # GH12541
212
+ df_inf = DataFrame ({'x' : [1 , 2 , 3 ], 'y' : [1. , 2. , np .Inf ]})
213
+ df_date = DataFrame ({'x' : [1 , 2 , 3 ], 'y' : pd .date_range ('20130101' ,periods = 3 )})
214
+ df_inf_date = DataFrame ({'x' : [1 , 2 , 3 ], 'y' : [1. , 2. , np .Inf ],
215
+ 'z' : pd .date_range ('20170101' ,periods = 3 )})
216
+
217
+ expected_1 = DataFrame ([[1 ,1 ],[2 ,2 ],[2 ,2 ]], columns = ['x' ,'y' ], dtype = float )
218
+ expected_2 = DataFrame ([[1 ,1 ,1 ],[2 ,2 ,2 ],[2 ,2 ,2 ]], columns = ['x' ,'y' ,'z' ], dtype = float )
219
+
220
+ self .assert_frame_equal (df_inf .rolling (window = 2 ).count (), expected_1 )
221
+ self .assert_frame_equal (df_date .rolling (window = 2 ).count (), expected_1 )
222
+ self .assert_frame_equal (df_inf_date .rolling (window = 2 ).count (), expected_2 )
223
+
210
224
def test_window_with_args (self ):
211
225
tm ._skip_if_no_scipy ()
212
226
0 commit comments