@@ -234,13 +234,15 @@ def test_reindex_categorical():
234
234
tm .assert_series_equal (result , expected )
235
235
236
236
# partial reindexing
237
- expected = Series (Categorical (values = ["b" , "c" ], categories = ["a" , "b" , "c" ]))
238
- expected .index = [1 , 2 ]
237
+ expected = Series (
238
+ Categorical (values = ["b" , "c" ], categories = ["a" , "b" , "c" ]), index = range (1 , 3 )
239
+ )
239
240
result = s .reindex ([1 , 2 ])
240
241
tm .assert_series_equal (result , expected )
241
242
242
- expected = Series (Categorical (values = ["c" , np .nan ], categories = ["a" , "b" , "c" ]))
243
- expected .index = [2 , 3 ]
243
+ expected = Series (
244
+ Categorical (values = ["c" , np .nan ], categories = ["a" , "b" , "c" ]), index = range (2 , 4 )
245
+ )
244
246
result = s .reindex ([2 , 3 ])
245
247
tm .assert_series_equal (result , expected )
246
248
@@ -261,24 +263,24 @@ def test_reindex_fill_value():
261
263
# floats
262
264
floats = Series ([1.0 , 2.0 , 3.0 ])
263
265
result = floats .reindex ([1 , 2 , 3 ])
264
- expected = Series ([2.0 , 3.0 , np .nan ], index = [ 1 , 2 , 3 ] )
266
+ expected = Series ([2.0 , 3.0 , np .nan ], index = range ( 1 , 4 ) )
265
267
tm .assert_series_equal (result , expected )
266
268
267
269
result = floats .reindex ([1 , 2 , 3 ], fill_value = 0 )
268
- expected = Series ([2.0 , 3.0 , 0 ], index = [ 1 , 2 , 3 ] )
270
+ expected = Series ([2.0 , 3.0 , 0 ], index = range ( 1 , 4 ) )
269
271
tm .assert_series_equal (result , expected )
270
272
271
273
# -----------------------------------------------------------
272
274
# ints
273
275
ints = Series ([1 , 2 , 3 ])
274
276
275
277
result = ints .reindex ([1 , 2 , 3 ])
276
- expected = Series ([2.0 , 3.0 , np .nan ], index = [ 1 , 2 , 3 ] )
278
+ expected = Series ([2.0 , 3.0 , np .nan ], index = range ( 1 , 4 ) )
277
279
tm .assert_series_equal (result , expected )
278
280
279
281
# don't upcast
280
282
result = ints .reindex ([1 , 2 , 3 ], fill_value = 0 )
281
- expected = Series ([2 , 3 , 0 ], index = [ 1 , 2 , 3 ] )
283
+ expected = Series ([2 , 3 , 0 ], index = range ( 1 , 4 ) )
282
284
assert issubclass (result .dtype .type , np .integer )
283
285
tm .assert_series_equal (result , expected )
284
286
@@ -287,23 +289,23 @@ def test_reindex_fill_value():
287
289
objects = Series ([1 , 2 , 3 ], dtype = object )
288
290
289
291
result = objects .reindex ([1 , 2 , 3 ])
290
- expected = Series ([2 , 3 , np .nan ], index = [ 1 , 2 , 3 ] , dtype = object )
292
+ expected = Series ([2 , 3 , np .nan ], index = range ( 1 , 4 ) , dtype = object )
291
293
tm .assert_series_equal (result , expected )
292
294
293
295
result = objects .reindex ([1 , 2 , 3 ], fill_value = "foo" )
294
- expected = Series ([2 , 3 , "foo" ], index = [ 1 , 2 , 3 ] , dtype = object )
296
+ expected = Series ([2 , 3 , "foo" ], index = range ( 1 , 4 ) , dtype = object )
295
297
tm .assert_series_equal (result , expected )
296
298
297
299
# ------------------------------------------------------------
298
300
# bools
299
301
bools = Series ([True , False , True ])
300
302
301
303
result = bools .reindex ([1 , 2 , 3 ])
302
- expected = Series ([False , True , np .nan ], index = [ 1 , 2 , 3 ] , dtype = object )
304
+ expected = Series ([False , True , np .nan ], index = range ( 1 , 4 ) , dtype = object )
303
305
tm .assert_series_equal (result , expected )
304
306
305
307
result = bools .reindex ([1 , 2 , 3 ], fill_value = False )
306
- expected = Series ([False , True , False ], index = [ 1 , 2 , 3 ] )
308
+ expected = Series ([False , True , False ], index = range ( 1 , 4 ) )
307
309
tm .assert_series_equal (result , expected )
308
310
309
311
@@ -318,7 +320,7 @@ def test_reindex_fill_value_datetimelike_upcast(dtype, fill_value):
318
320
ser = Series ([NaT ], dtype = dtype )
319
321
320
322
result = ser .reindex ([0 , 1 ], fill_value = fill_value )
321
- expected = Series ([NaT , fill_value ], index = [ 0 , 1 ] , dtype = object )
323
+ expected = Series ([NaT , fill_value ], index = range ( 2 ) , dtype = object )
322
324
tm .assert_series_equal (result , expected )
323
325
324
326
0 commit comments