@@ -397,6 +397,13 @@ def test_shift_axis1_multiple_blocks(self, using_array_manager):
397
397
result = df3 .shift (2 , axis = 1 )
398
398
399
399
expected = df3 .take ([- 1 , - 1 , 0 , 1 , 2 ], axis = 1 )
400
+ # Explicit cast to float to avoid implicit cast when setting nan.
401
+ # Column names aren't unique, so directly calling `expected.astype` won't work.
402
+ expected = expected .pipe (
403
+ lambda df : df .set_axis (range (df .shape [1 ]), axis = 1 )
404
+ .astype ({0 : "float" , 1 : "float" })
405
+ .set_axis (df .columns , axis = 1 )
406
+ )
400
407
expected .iloc [:, :2 ] = np .nan
401
408
expected .columns = df3 .columns
402
409
@@ -410,6 +417,13 @@ def test_shift_axis1_multiple_blocks(self, using_array_manager):
410
417
result = df3 .shift (- 2 , axis = 1 )
411
418
412
419
expected = df3 .take ([2 , 3 , 4 , - 1 , - 1 ], axis = 1 )
420
+ # Explicit cast to float to avoid implicit cast when setting nan.
421
+ # Column names aren't unique, so directly calling `expected.astype` won't work.
422
+ expected = expected .pipe (
423
+ lambda df : df .set_axis (range (df .shape [1 ]), axis = 1 )
424
+ .astype ({3 : "float" , 4 : "float" })
425
+ .set_axis (df .columns , axis = 1 )
426
+ )
413
427
expected .iloc [:, - 2 :] = np .nan
414
428
expected .columns = df3 .columns
415
429
0 commit comments