Skip to content

Commit 4a81c1f

Browse files
committed
add test for concat to preserve indices with same name
1 parent ae16e8c commit 4a81c1f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pandas/tests/reshape/test_concat.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,18 @@ def test_concat_ignore_index(self, sort):
12791279

12801280
tm.assert_frame_equal(v1, expected)
12811281

1282+
def test_concat_same_index_names(self):
1283+
# GH13475
1284+
index1 = pd.Index(['a', 'b'], name='idx')
1285+
index2 = pd.Index(['b', 'c'], name='idx')
1286+
1287+
frame1 = pd.DataFrame({'x': [1, 2]}, index=index1)
1288+
frame2 = pd.DataFrame({'x': [2, 3]}, index=index2)
1289+
1290+
result = pd.concat([frame1, frame2], axis=1)
1291+
1292+
assert result.index.name == 'idx'
1293+
12821294
def test_concat_multiindex_with_keys(self):
12831295
index = MultiIndex(
12841296
levels=[["foo", "bar", "baz", "qux"], ["one", "two", "three"]],

0 commit comments

Comments
 (0)