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

Assigning a string index as a column once can make further assignments affect both index and column. #13522

Closed
tjader opened this issue Jun 27, 2016 · 1 comment · Fixed by #14005
Labels
Bug Compat pandas objects compatability with Numpy or Python functions Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@tjader
Copy link

tjader commented Jun 27, 2016

If you assign the dataframe's index to as a column as well, without resetting the index, any subsequent assignments on the column seem to affect both the column as well as the index.
The behaviour is there for Index, Int64Index, and Float64Index but not DatetimeIndex.

Code Sample, a copy-pastable example if possible.

>>> import pandas as pd
>>> df=pd.DataFrame(index=['A', 'B', 'C'])
>>> df['X']=df.index
>>> df
   X
A  A
B  B
C  C
>>> df['X']=['x', 'y', 'z']
>>> df
   X
x  x
y  y
z  z
>>> df.ix[0, 'X']='q'
>>> df
   X
q  q
y  y
z  z

Expected Output

   X
A  x
B  y
C  z

output of pd.show_versions()

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

pandas: 0.18.1
nose: 1.3.7
pip: 8.1.2
setuptools: 23.0.0
Cython: 0.24
numpy: 1.10.4
scipy: 0.17.1
statsmodels: None
xarray: 0.7.2
IPython: None
sphinx: None
patsy: None
dateutil: 2.4.1
pytz: 2016.4
blosc: None
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.5.2
matplotlib: 1.5.1
openpyxl: 2.3.2
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.13
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.40.0
pandas_datareader: None
@jreback jreback added Bug Indexing Related to indexing on series/frames, not to indexes themselves Compat pandas objects compatability with Numpy or Python functions labels Jun 28, 2016
@jreback jreback added this to the 0.19.0 milestone Jun 28, 2016
@jreback
Copy link
Contributor

jreback commented Jun 28, 2016

hmm these are supposed to be copied when coming from s column
not sure what happened

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Compat pandas objects compatability with Numpy or Python functions Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
2 participants