@@ -209,20 +209,24 @@ def f():
209
209
210
210
def test_count_nonnumeric_types (self ):
211
211
# GH12541
212
- cols = ['int' , 'float' , 'string' , 'datetime' , 'timedelta' ,
213
- 'fl_inf' , 'fl_nan' , 'str_nan' , 'dt_nat' ]
212
+ cols = ['int' , 'float' , 'string' , 'datetime' , 'timedelta' , 'periods' ,
213
+ 'fl_inf' , 'fl_nan' , 'str_nan' , 'dt_nat' , 'periods_nat' ]
214
214
215
215
df = DataFrame (
216
216
{'int' : [1 , 2 , 3 ],
217
217
'float' : [4. , 5. , 6. ],
218
218
'string' : list ('abc' ),
219
219
'datetime' : pd .date_range ('20170101' , periods = 3 ),
220
220
'timedelta' : pd .timedelta_range ('1 s' , periods = 3 , freq = 's' ),
221
+ 'periods' : [pd .Period ('2012-01' ), pd .Period ('2012-02' ),
222
+ pd .Period ('2012-03' )],
221
223
'fl_inf' : [1. , 2. , np .Inf ],
222
224
'fl_nan' : [1. , 2. , np .NaN ],
223
225
'str_nan' : ['aa' , 'bb' , np .NaN ],
224
226
'dt_nat' : [pd .Timestamp ('20170101' ), pd .Timestamp ('20170203' ),
225
- pd .Timestamp (None )]},
227
+ pd .Timestamp (None )],
228
+ 'periods_nat' : [pd .Period ('2012-01' ), pd .Period ('2012-02' ),
229
+ pd .Period (None )]},
226
230
columns = cols )
227
231
228
232
expected = DataFrame (
@@ -231,10 +235,12 @@ def test_count_nonnumeric_types(self):
231
235
'string' : [1. , 2. , 2. ],
232
236
'datetime' : [1. , 2. , 2. ],
233
237
'timedelta' : [1. , 2. , 2. ],
238
+ 'periods' : [1. , 2. , 2. ],
234
239
'fl_inf' : [1. , 2. , 2. ],
235
240
'fl_nan' : [1. , 2. , 1. ],
236
241
'str_nan' : [1. , 2. , 1. ],
237
- 'dt_nat' : [1. , 2. , 1. ]},
242
+ 'dt_nat' : [1. , 2. , 1. ],
243
+ 'periods_nat' : [1. , 2. , 1. ]},
238
244
columns = cols )
239
245
240
246
self .assert_frame_equal (df .rolling (window = 2 ).count (), expected )
0 commit comments