Closed
Description
Code Sample, a copy-pastable example if possible
# It's pretty simple but it doesn't work.
# Here stocks is inside a class which type is pd.Series.
# I tried to print money / price * (1-r) and found it was not zero.
# However, self.stocks[ticker] is never changed which confuses me
self.stocks[ticker] += money / price * (1 - r)
Problem description
See the comments above. It only happens when I tried to use a certain set of data but works for other situations. I've tried to change the value of self.stocks[name] and something more strange happened.
# this works
self.stocks[ticker] = 6
self.stocks[ticker] += money / price * (1 - r)
# I was able to see the different value printed after the line
# but if I change it to
if self.stocks[ticker] == 0:
self.stocks[ticker] = 0
self.stocks[ticker] += money / price* (1 - r)
# it repeated the unchanged result which drove me mad
Expected Output
self.stocks[ticker] should be changed
Output of pd.show_versions()
# Paste the output here pd.show_versions() here
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.0.final.0
python-bits: 64
OS: Darwin
OS-release: 16.3.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: zh_CN.UTF-8
LOCALE: zh_CN.UTF-8
pandas: 0.19.2
nose: None
pip: 9.0.1
setuptools: 32.2.0
Cython: None
numpy: 1.12.0
scipy: 0.18.1
statsmodels: None
xarray: None
IPython: 5.1.0
sphinx: None
patsy: None
dateutil: 2.6.0
pytz: 2016.10
blosc: None
bottleneck: None
tables: None
numexpr: 2.6.2
matplotlib: 2.0.0
openpyxl: 2.4.2
xlrd: 1.0.0
xlwt: None
xlsxwriter: None
lxml: 3.7.2
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.9.5
boto: None
pandas_datareader: None