Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

wesm opened this issue Sep 19, 2016 · 0 comments
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Milestone

Comments

@wesm
Copy link
Member

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 jreback added Bug Indexing Related to indexing on series/frames, not to indexes themselves Difficulty Intermediate labels Sep 19, 2016
@jreback jreback added this to the Next Major Release milestone Sep 19, 2016
@jreback jreback added the Reshaping Concat, Merge/Join, Stack/Unstack, Explode label Sep 19, 2016
@rsmith54 rsmith54 mentioned this issue Sep 20, 2016
4 tasks
@bkandel bkandel mentioned this issue Sep 23, 2016
4 tasks
@jreback jreback modified the milestones: 0.19.1, Next Major Release Oct 8, 2016
@jreback jreback closed this as completed in 16b64f1 Oct 9, 2016
tworec pushed a commit to RTBHOUSE/pandas that referenced this issue Oct 21, 2016
closes pandas-dev#14252
Fixes a bug where `pd.concat` didn't propagate the names of keys used to
create  a hierarchical index.

Author: Ben Kandel <[email protected]>

Closes pandas-dev#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants