@@ -1279,6 +1279,33 @@ def test_concat_ignore_index(self, sort):
1279
1279
1280
1280
tm .assert_frame_equal (v1 , expected )
1281
1281
1282
+ @pytest .mark .parametrize (
1283
+ "input_names,output_name" ,
1284
+ [
1285
+ (["idx" , "idx" ], "idx" ),
1286
+ (["idx" , None ], "idx" ),
1287
+ ([None , None ], None ),
1288
+ (["idx1" , "idx2" ], None ),
1289
+ (["idx" , "idx" , None ], "idx" ),
1290
+ (["idx1" , "idx2" , None ], None ),
1291
+ ],
1292
+ )
1293
+ def test_concat_same_index_names (self , input_names , output_name ):
1294
+ # GH13475
1295
+ indices = [pd .Index (["a" , "b" , "c" ], name = n ) for n in input_names ]
1296
+ frames = [
1297
+ pd .DataFrame ({c : [0 , 1 , 2 ]}, index = i )
1298
+ for i , c in zip (indices , ["x" , "y" , "z" ])
1299
+ ]
1300
+ result = pd .concat (frames , axis = 1 )
1301
+
1302
+ exp_ind = pd .Index (["a" , "b" , "c" ], name = output_name )
1303
+ expected = pd .DataFrame (
1304
+ {c : [0 , 1 , 2 ] for _ , c in zip (input_names , ["x" , "y" , "z" ])}, index = exp_ind
1305
+ )
1306
+
1307
+ tm .assert_frame_equal (result , expected )
1308
+
1282
1309
def test_concat_multiindex_with_keys (self ):
1283
1310
index = MultiIndex (
1284
1311
levels = [["foo" , "bar" , "baz" , "qux" ], ["one" , "two" , "three" ]],
0 commit comments