BUG: keys argument in pandas.concat does not preserve Index name #14252

Closed
wesm opened this Issue Sep 19, 2016 · 0 comments

Comments

Projects
None yet
2 participants
Owner

wesm commented Sep 19, 2016

Code Sample, a copy-pastable example if possible

df = pd.DataFrame({'foo': [1, 2, 3, 4],
                   'bar': [0.1, 0.2, 0.3, 0.4]})
index = pd.Index(['a', 'b'], name='baz')

concatted = pd.concat([df, df], keys=index)
concatted.index.names

## -- End pasted text --
Out[3]: FrozenList([None, None])

Expected Output

FrozenList(['baz', None])

output of pd.show_versions()

A few days older than master:

commit: 5e2f9da6e8e713bd89cfe8760e63583ea7d29879

jreback added this to the Next Major Release milestone Sep 19, 2016

jreback added the Reshaping label Sep 19, 2016

This was referenced Sep 20, 2016

@jreback jreback modified the milestone: 0.19.1, Next Major Release Oct 8, 2016

jreback closed this in 16b64f1 Oct 9, 2016

@tworec tworec added a commit to RTBHOUSE/pandas that referenced this issue Oct 21, 2016

@tworec Ben Kandel + tworec BUG: Fix concat key name
closes #14252
Fixes a bug where `pd.concat` didn't propagate the names of keys used to
create  a hierarchical index.

Author: Ben Kandel <ben.kandel@gmail.com>

Closes #14292 from bkandel/fix_concat_key_name and squashes the following commits:

cdc76f6 [Ben Kandel] take out _ensure_index
4a301f8 [Ben Kandel] put back in Index coercion
d8e2c17 [Ben Kandel] remove coercion to Index before _ensure_index
44932cc [Ben Kandel] changed whatsnew entry to 0.19.1
c51df19 [Ben Kandel] _ensure_index
b54b081 [Ben Kandel] simplified logic
3256119 [Ben Kandel] typo
789ecd4 [Ben Kandel] use _ensure_index
350e724 [Ben Kandel] simplified logic
9615a69 [Ben Kandel] extra tests
5c0108b [Ben Kandel] comments
dd3c4cc [Ben Kandel] comments
5cd8392 [Ben Kandel] added test for names
bc5f1fb [Ben Kandel] cleanup
ef6db68 [Ben Kandel] BUG: Propagate key names in concat.
8720013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment