We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 97ad1cf commit d20cb18Copy full SHA for d20cb18
pandas/tools/tests/test_merge.py
@@ -822,6 +822,21 @@ def test_concat_dict(self):
822
expected = concat([frames[k] for k in keys], keys=keys)
823
tm.assert_frame_equal(result, expected)
824
825
+ def test_concat_multiindex_with_keys(self):
826
+ index = MultiIndex(levels=[['foo', 'bar', 'baz', 'qux'],
827
+ ['one', 'two', 'three']],
828
+ labels=[[0, 0, 0, 1, 1, 2, 2, 3, 3, 3],
829
+ [0, 1, 2, 0, 1, 1, 2, 0, 1, 2]],
830
+ names=['first', 'second'])
831
+ frame = DataFrame(np.random.randn(10, 3), index=index,
832
+ columns=Index(['A', 'B', 'C'], name='exp'))
833
+ result = concat([frame, frame], keys=[0, 1], names=['iteration'])
834
+
835
+ self.assertEqual(result.index.names, ['iteration'] + index.names)
836
+ tm.assert_frame_equal(result.ix[0], frame)
837
+ tm.assert_frame_equal(result.ix[1], frame)
838
+ self.assertEqual(result.index.nlevels, 3)
839
840
def test_concat_keys_and_levels(self):
841
df = DataFrame(np.random.randn(1, 3))
842
df2 = DataFrame(np.random.randn(1, 4))
0 commit comments