Skip to content

Behaviour of concat with empty Series has changed between 0.18.0 and 0.18.1 #13154

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
bastewart opened this issue May 12, 2016 · 3 comments
Closed
Labels
Reshaping Concat, Merge/Join, Stack/Unstack, Explode Usage Question

Comments

@bastewart
Copy link

Code Sample, a copy-pastable example if possible

import pandas as pd

s_empty = pd.Series()
s_filled = pd.Series([1, 2, 3, 4, 5])

pd.concat([s_empty, s_filled], 1)

Expected Output

Expect to be consistent between versions: previously would not add any columns for the empty Series, now a column of NaN is appended. (I can not see this mentioned in the what's new so think this is an unintended change.)

In 0.18.0:

   0
0  1
1  2
2  3
3  4
4  5

In 0.18.1 (and tested on 0.18.1+25.g4aa6323):

    0  1
0 NaN  1
1 NaN  2
2 NaN  3
3 NaN  4
4 NaN  5

output of pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.11.final.0
python-bits: 64
OS: Darwin
OS-release: 15.4.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8

pandas: 0.18.1
nose: None
pip: 8.1.2
setuptools: 21.0.0
Cython: None
numpy: 1.11.0
scipy: 0.17.0
statsmodels: None
xarray: None
IPython: 4.2.0
sphinx: None
patsy: None
dateutil: 2.5.3
pytz: 2016.4
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

In my 0.18.0 environment the only differences in show_versions is the pandas entry and pandas_datareader is not present.

@jorisvandenbossche
Copy link
Member

This was regarded as a bug (#11082), and was fixed for 0.18.1 (PR #12846).

So it is mentioned in the whatsnew docs ("Bug in concat doesn't handle empty Series properly"), but of course difficult to find in such a long list, and it was also not put in the API changes section (it is always a bit subjective whether something is clearly a bug fix or also worth mentioning as an API change, as people can rely on the buggy behaviour. You could argue that in this case a API change mention would be worth it).

@jorisvandenbossche jorisvandenbossche added Reshaping Concat, Merge/Join, Stack/Unstack, Explode Usage Question labels May 12, 2016
@jorisvandenbossche jorisvandenbossche added this to the No action milestone May 12, 2016
@bastewart
Copy link
Author

Ah, thanks for clarifying, sorry I missed that!

@jorisvandenbossche
Copy link
Member

No problem, and thanks for reporting anyway!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reshaping Concat, Merge/Join, Stack/Unstack, Explode Usage Question
Projects
None yet
Development

No branches or pull requests

2 participants