pd.concat fails if given repeated keys #20816
Labels
Needs Tests
Unit test(s) needed to prevent regressions
Reshaping
Concat, Merge/Join, Stack/Unstack, Explode
Milestone
Uh oh!
There was an error while loading. Please reload this page.
Code Sample, a copy-pastable example if possible
Expected Output
Since the indices of the Series don't conflict, it should be fine to use the same key for several rows (after all, it works fine without any keys at all). None of these calls should raise an exception and the objects they return should not be broken (see below for what I mean). Expected output:
Problem description
This is similar to issue #20565 (but even worse, IMO). I think the problem is that
pd.concat
creates a Series with duplicate entries in its index. This is illustrated by the broken object one of the above calls creates:Lots of operations fail on this object. For instance,
broken.sort_index()
raises "ValueError: operands could not be broadcast together with shapes (7,) (3,) (7,)".Output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 2.7.6.final.0
python-bits: 64
OS: Linux
OS-release: 4.3.5-smp-811.22.0.0
machine: x86_64
processor:
byteorder: little
LC_ALL: en_US.UTF-8
LANG: None
LOCALE: None.None
pandas: 0.22.0
pytest: None
pip: None
setuptools: None
Cython: None
numpy: 1.13.3
scipy: 1.0.0
pyarrow: None
xarray: None
IPython: 2.0.0
sphinx: None
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2018.3
blosc: None
bottleneck: None
tables: 3.1.1
numexpr: 2.5
feather: None
matplotlib: 1.5.2
openpyxl: None
xlrd: 0.9.3
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: