@@ -256,36 +256,40 @@ def test_constructor_with_generator(self):
256
256
cat = Categorical ([0 , 1 , 2 ], categories = xrange (3 ))
257
257
tm .assert_categorical_equal (cat , exp )
258
258
259
- def test_constructor_with_datetimelike (self ):
260
-
261
- # 12077
262
- # constructor wwth a datetimelike and NaT
263
-
264
- for dtl in [date_range ('1995-01-01 00:00:00' , periods = 5 , freq = 's' ),
265
- date_range ('1995-01-01 00:00:00' , periods = 5 ,
266
- freq = 's' , tz = 'US/Eastern' ),
267
- timedelta_range ('1 day' , periods = 5 , freq = 's' )]:
268
-
269
- s = Series (dtl )
270
- c = Categorical (s )
271
- expected = type (dtl )(s )
272
- expected .freq = None
273
- tm .assert_index_equal (c .categories , expected )
274
- tm .assert_numpy_array_equal (c .codes , np .arange (5 , dtype = 'int8' ))
275
-
276
- # with NaT
277
- s2 = s .copy ()
278
- s2 .iloc [- 1 ] = NaT
279
- c = Categorical (s2 )
280
- expected = type (dtl )(s2 .dropna ())
281
- expected .freq = None
282
- tm .assert_index_equal (c .categories , expected )
283
-
284
- exp = np .array ([0 , 1 , 2 , 3 , - 1 ], dtype = np .int8 )
285
- tm .assert_numpy_array_equal (c .codes , exp )
286
-
287
- result = repr (c )
288
- assert 'NaT' in result
259
+ @pytest .mark .parametrize ("dtl" , [
260
+ date_range ("1995-01-01 00:00:00" , periods = 5 , freq = "s" ),
261
+ date_range ("1995-01-01 00:00:00" , periods = 5 ,
262
+ freq = "s" , tz = "US/Eastern" ),
263
+ timedelta_range ("1 day" , periods = 5 , freq = "s" )
264
+ ])
265
+ def test_constructor_with_datetimelike (self , dtl ):
266
+ # see gh-12077
267
+ # constructor with a datetimelike and NaT
268
+
269
+ s = Series (dtl )
270
+ c = Categorical (s )
271
+
272
+ expected = type (dtl )(s )
273
+ expected .freq = None
274
+
275
+ tm .assert_index_equal (c .categories , expected )
276
+ tm .assert_numpy_array_equal (c .codes , np .arange (5 , dtype = "int8" ))
277
+
278
+ # with NaT
279
+ s2 = s .copy ()
280
+ s2 .iloc [- 1 ] = NaT
281
+ c = Categorical (s2 )
282
+
283
+ expected = type (dtl )(s2 .dropna ())
284
+ expected .freq = None
285
+
286
+ tm .assert_index_equal (c .categories , expected )
287
+
288
+ exp = np .array ([0 , 1 , 2 , 3 , - 1 ], dtype = np .int8 )
289
+ tm .assert_numpy_array_equal (c .codes , exp )
290
+
291
+ result = repr (c )
292
+ assert "NaT" in result
289
293
290
294
def test_constructor_from_index_series_datetimetz (self ):
291
295
idx = date_range ('2015-01-01 10:00' , freq = 'D' , periods = 3 ,
0 commit comments