Skip to content
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

Allow concat names arg to rename existing MultiIndex level. #1419

Closed
lodagro opened this issue Jun 7, 2012 · 1 comment

Comments

@lodagro
Copy link
Contributor

commented Jun 7, 2012

In [67]: a = pandas.DataFrame(np.random.rand(3,3),
   ....:                      columns=list('ABC'),
   ....:                      index=pandas.Index(list('abc'), name='index_a'))

In [68]: b = pandas.DataFrame(np.random.rand(3,3),
   ....:                      columns=list('ABC'),
   ....:                      index=pandas.Index(list('abc'), name='index_b'))

In [69]: a
Out[69]:
                A         B         C
index_a
a        0.734551  0.364354  0.989970
b        0.356027  0.625983  0.855296
c        0.895759  0.144406  0.068718

In [70]: b
Out[70]:
                A         B         C
index_b
a        0.130305  0.981312  0.541476
b        0.046006  0.369983  0.822214
c        0.621787  0.047847  0.420459

In [71]: c = pandas.concat([a, b], keys=['key0', 'key1'], names=['lvl0'])

In [72]: c
Out[72]:
                     A         B         C
lvl0 index_a
key0 a        0.734551  0.364354  0.989970
     b        0.356027  0.625983  0.855296
     c        0.895759  0.144406  0.068718
key1 a        0.130305  0.981312  0.541476
     b        0.046006  0.369983  0.822214
     c        0.621787  0.047847  0.420459

In [73]: c = pandas.concat([a, b], keys=['key0', 'key1'], names=['lvl0', 'lvl1'])
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
...
AssertionError:

@wesm wesm closed this in b1edf54 Jun 12, 2012

@wesm

This comment has been minimized.

Copy link
Member

commented Jun 12, 2012

This is done in git master

yarikoptic added a commit to neurodebian/pandas that referenced this issue Jun 21, 2012
Merge tag 'v0.8.0b2' into debian-0.8
Version 0.8.0 beta 2

* tag 'v0.8.0b2': (37 commits)
  RLS: 0.8.0 beta 2
  BUG: bytes_to_str for read_csv
  BUG: import BytesIO for py3compat
  BUG: fix compat errors for yahoo data reader
  ENH: convert datetime.datetime ourselves, 15x speedup
  Make tox work across versions of Python from 2.5 to 3.2
  Reenable py31 and py32 in .travis.yml
  TST: test coverage
  TST: oops, delete stray line
  REF: factor out ujson extension into pandasjson for now
  TST: eliminate copies in datetime64 serialization; don't copy data in DatetimeIndex, close pandas-dev#1320
  DOC: refresh time zone docs close pandas-dev#1447
  BUG: always raise exception when concat keys aren't found in passed levels, close pandas-dev#1406
  ENH: implement passed quantile array to qcut and document that plus factors, close pandas-dev#1407
  ENH: clearer out of bounds error message in cut/qcut, close pandas-dev#1409
  ENH: allow renaming of index levels when concatenating, close pandas-dev#1419
  BUG: fix MultiIndex bugs described in pandas-dev#1401
  DOC: release notes
  BUG: implement multiple DataFrame.join / merge on non-unique indexes by multiple merges, close pandas-dev#1421
  REF: remove offset names from pandas namespace
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.