Skip to content

Commit 26c86a5

Browse files
author
Giacomo Ferroni
committed
Test added for GH12541
1 parent ea49e77 commit 26c86a5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pandas/tests/test_window.py

+14
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,20 @@ def f():
207207
'A', 'ra', 'std'), ('B', 'rb', 'mean'), ('B', 'rb', 'std')])
208208
tm.assert_frame_equal(result, expected, check_like=True)
209209

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+
210224
def test_window_with_args(self):
211225
tm._skip_if_no_scipy()
212226

0 commit comments

Comments
 (0)