@@ -1280,29 +1280,36 @@ def test_concat_ignore_index(self, sort):
1280
1280
tm .assert_frame_equal (v1 , expected )
1281
1281
1282
1282
@pytest .mark .parametrize (
1283
- "input_names,output_name " ,
1283
+ "name_in1,name_in2,name_in3,name_out " ,
1284
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 ),
1285
+ ("idx" , "idx" , "idx" , "idx" ),
1286
+ ("idx" , "idx" , None , "idx" ),
1287
+ ("idx" , None , None , "idx" ),
1288
+ ("idx1" , "idx2" , None , None ),
1289
+ ("idx1" , "idx1" , "idx2" , None ),
1290
+ ("idx1" , "idx2" , "idx3" , None ),
1291
+ (None , None , None , None ),
1291
1292
],
1292
1293
)
1293
- def test_concat_same_index_names (self , input_names , output_name ):
1294
+ def test_concat_same_index_names (self , name_in1 , name_in2 , name_in3 , name_out ):
1294
1295
# GH13475
1295
- indices = [pd .Index (["a" , "b" , "c" ], name = n ) for n in input_names ]
1296
+ indices = [
1297
+ pd .Index (["a" , "b" , "c" ], name = name_in1 ),
1298
+ pd .Index (["b" , "c" , "d" ], name = name_in2 ),
1299
+ pd .Index (["c" , "d" , "e" ], name = name_in3 ),
1300
+ ]
1296
1301
frames = [
1297
1302
pd .DataFrame ({c : [0 , 1 , 2 ]}, index = i )
1298
1303
for i , c in zip (indices , ["x" , "y" , "z" ])
1299
1304
]
1300
1305
result = pd .concat (frames , axis = 1 )
1301
1306
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
- )
1307
+ exp_ind = pd .Index (["a" , "b" , "c" , "d" , "e" ], name = name_out )
1308
+ expected = pd .DataFrame ({
1309
+ "x" : [0 , 1 , 2 , np .nan , np .nan ],
1310
+ "y" : [np .nan , 0 , 1 , 2 , np .nan ],
1311
+ "z" : [np .nan , np .nan , 0 , 1 , 2 ],
1312
+ }, index = exp_ind )
1306
1313
1307
1314
tm .assert_frame_equal (result , expected )
1308
1315
0 commit comments