Skip to content

name property changes unexpectedly after Series.append #15049

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
shuuchen opened this issue Jan 4, 2017 · 5 comments
Closed

name property changes unexpectedly after Series.append #15049

shuuchen opened this issue Jan 4, 2017 · 5 comments
Labels
Reshaping Concat, Merge/Join, Stack/Unstack, Explode Usage Question

Comments

@shuuchen
Copy link

shuuchen commented Jan 4, 2017

Hi, I have tried Series.append but the name property changes unexpectedly.

a = pd.Series(name='a')
b = pd.Series(name='b')
c = pd.Series()

# a.name turns to be None if a.name is different with b.name
a.append(b) # a.name is None after append

# a.name turns to be None if c dose not have a name
a.append(c) # a.name is None after append

# a.name remains unchanged
a.append(pd.Series(name=a.name)) # a.name dose not change

Problem description

As a new series is appended to an old one, the name of the old series should be unchanged.
This should not be satisfied only when the name of the new series is explicitly specified.
However, the above problem happens.

Expected Output

Whenever a.append(b) or a.append(c) is done, a.name should remain unchanged, which is 'a'.

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.5.1.final.0 python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 94 Stepping 3, GenuineIntel byteorder: little LC_ALL: None LANG: None LOCALE: None.None

pandas: 0.19.1
nose: 1.3.7
pip: 8.1.2
setuptools: 19.2
Cython: 0.23.4
numpy: 1.11.0
scipy: 0.17.0
statsmodels: 0.6.1
xarray: None
IPython: 4.1.2
sphinx: 1.3.1
patsy: 0.4.0
dateutil: 2.5.1
pytz: 2016.2
blosc: None
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.5.1
matplotlib: 1.5.1
openpyxl: 2.3.2
xlrd: 0.9.4
xlwt: 1.0.0
xlsxwriter: 0.8.4
lxml: 3.6.0
bs4: 4.4.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.12
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.39.0
pandas_datareader: None

@jorisvandenbossche
Copy link
Member

We have a lot of issues (and fixes) of names getting lost, see #9862 for an overview.
But I think the behaviour here (only retaining name if the names match) is on purpose and tested behaviour (@sinhrks?) What does not mean of course that this choice cannot be challenged.

@shuuchen
Copy link
Author

shuuchen commented Jan 5, 2017

thanks!

@jreback
Copy link
Contributor

jreback commented Jan 5, 2017

yes this is correct and expected.

@jreback jreback closed this as completed Jan 5, 2017
@jreback jreback added Reshaping Concat, Merge/Join, Stack/Unstack, Explode Usage Question labels Jan 5, 2017
@jreback jreback added this to the No action milestone Jan 5, 2017
@Michael-E-Rose
Copy link

If it's expected and desired it should be mentioned in the documentation: https://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.append.html

@jorisvandenbossche
Copy link
Member

@Michael-E-Rose indeed (and you are welcome to do a small PR to update it!)

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

4 participants