Skip to content

BUG: concat with dataframes heterogeneous in length and tuple keys #14438

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
dubourg opened this issue Oct 17, 2016 · 1 comment · Fixed by #14449
Closed

BUG: concat with dataframes heterogeneous in length and tuple keys #14438

dubourg opened this issue Oct 17, 2016 · 1 comment · Fixed by #14449
Labels
Bug Regression Functionality that used to work in a prior pandas version Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Milestone

Comments

@dubourg
Copy link
Contributor

dubourg commented Oct 17, 2016

A small, complete example of the issue

import numpy as np
import pandas as pd
df1 = pd.DataFrame(np.random.rand(4).reshape((2, 2)), columns=list('AB'))
df2 = pd.DataFrame(np.random.rand(6).reshape((3, 2)), columns=list('AB'))
print(pd.concat([df1, df2], keys=[('bee', 'bah'), ('bee', 'bouh')], names=['zig', 'zag', None]))

Expected Output (works w/ 0.18.1)

                   A         B
zig zag                       
bee bah  0  0.689411  0.364650
         1  0.143786  0.415858
    bouh 0  0.557942  0.646434
         1  0.551938  0.695175
         2  0.991975  0.880451

0.19 raises

/path/to/lib/python3.4/site-packages/pandas/tools/merge.py in _make_concat_multiindex(indexes, keys, levels, names)
   1673         else:
   1674             codes, categories = _factorize_from_iterable(concat_index)
-> 1675             levels.append(categories)
   1676             label_list.append(codes)
   1677 

AttributeError: 'tuple' object has no attribute 'append'

Output of pd.show_versions()

## INSTALLED VERSIONS

commit: None
python: 3.4.5.final.0
python-bits: 64
OS: Linux
OS-release: 3.13.0-74-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG:
LOCALE: None.None

pandas: 0.19.0
nose: None
pip: 8.1.2
setuptools: 27.2.0
Cython: None
numpy: 1.11.2
scipy: 0.17.1
statsmodels: 0.6.1
xarray: None
IPython: 4.2.0
sphinx: 1.4.1
patsy: 0.4.1
dateutil: 2.5.3
pytz: 2016.7
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None
pandas_datareader: None

@chris-b1 chris-b1 added the Bug label Oct 19, 2016
@chris-b1 chris-b1 added this to the Next Major Release milestone Oct 19, 2016
@chris-b1 chris-b1 changed the title concat with dataframes heterogeneous in length and tuple keys raises AttributeError: 'tuple' object has no attribute 'append' (as of pandas 0.19) BUG: concat with dataframes heterogeneous in length and tuple keys Oct 19, 2016
@chris-b1
Copy link
Contributor

Thanks for the report, PRs welcome!

@jreback jreback added Reshaping Concat, Merge/Join, Stack/Unstack, Explode Difficulty Novice labels Oct 19, 2016
dubourg added a commit to dubourg/pandas that referenced this issue Oct 19, 2016
@jreback jreback modified the milestones: 0.19.1, Next Major Release Oct 20, 2016
jreback pushed a commit that referenced this issue Oct 20, 2016
@jorisvandenbossche jorisvandenbossche added the Regression Functionality that used to work in a prior pandas version label Oct 20, 2016
tworec pushed a commit to RTBHOUSE/pandas that referenced this issue Oct 21, 2016
jorisvandenbossche pushed a commit that referenced this issue Nov 1, 2016
…s in _factorize_from_iterables (fixes #14438)

(cherry picked from commit 0b6946b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Regression Functionality that used to work in a prior pandas version Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants