@@ -397,6 +397,13 @@ def test_shift_axis1_multiple_blocks(self, using_array_manager):
397397 result = df3 .shift (2 , axis = 1 )
398398
399399 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+ )
400407 expected .iloc [:, :2 ] = np .nan
401408 expected .columns = df3 .columns
402409
@@ -410,6 +417,13 @@ def test_shift_axis1_multiple_blocks(self, using_array_manager):
410417 result = df3 .shift (- 2 , axis = 1 )
411418
412419 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+ )
413427 expected .iloc [:, - 2 :] = np .nan
414428 expected .columns = df3 .columns
415429
0 commit comments