-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Cannot set value correctly #15413
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
Comments
you will need to show a copy-pastable example. |
Sorry for replying so slowly. My codes are pretty long. Unzip the attachment, cd into the directory and run ./process.py (with python3). The problem happens in line 194 of backtesting.py when the parameter n_days is 5 in line 34 of process.py. That is what I've shown above. |
@fduxiao that's not acceptable. Please show a copy-pastable example. If you think this is a bug, then it will need to be narrowed down to a tests case. |
When I tried to simplify the code I found the reason that I'd added a float to an element of an Series with dtype int64 and the result had been an int64, which caused this situation. Sorry for such a mistake and is there any good way to avoid it, since it's easy for one to forget a |
@fduxiao Based on what you describe of "added a float to an element of an Series with dtype int64 and the result had been an int64", I tried the following as a simple example:
So indeed, scalar indexing with |
This probably has some roots in numpy behaviour:
Numpy takes the route of "inplace operation should not alter dtype" (which is certainly also sensible), but seems to cast the right hand side for scalar indexing, but raises an error in the other cases. |
are there any plans to fix this? |
Code Sample, a copy-pastable example if possible
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.
Expected Output
self.stocks[ticker] should be changed
Output of
pd.show_versions()
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
The text was updated successfully, but these errors were encountered: