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

__idiv__ creates a copy? #12962

Closed
hhuuggoo opened this issue Apr 22, 2016 · 3 comments · Fixed by #17589
Closed

__idiv__ creates a copy? #12962

hhuuggoo opened this issue Apr 22, 2016 · 3 comments · Fixed by #17589
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Numeric Operations Arithmetic, Comparison, and Logical operations
Milestone

Comments

@hhuuggoo
Copy link

Code Sample, a copy-pastable example if possible

import pandas as pd
mylist = [pd.Series([1,2,3])]

for m in mylist:
    m /= 2.0
    print '***printing m***'
    print m
print
print '***mylist[0] - should be same as m, but isnt***'
print mylist[0]

observed output:

***printing m***
0    0.5
1    1.0
2    1.5
dtype: float64

***mylist[0] - should be same as m, but isnt***
0    1
1    2
2    3
dtype: int64

Expected Output

***printing m***
0    1
1    2
2    3
dtype: float64

***mylist[0] - should be same as m, but isnt***
0    1
1    2
2    3
dtype: int64

output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 2.7.11.final.0
python-bits: 64
OS: Darwin
OS-release: 14.5.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.18.0
nose: None
pip: 8.1.1
setuptools: 20.6.7
Cython: None
numpy: 1.11.0
scipy: None
statsmodels: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.5.2
pytz: 2016.3
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: None
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: None
boto: None

@jreback
Copy link
Contributor

jreback commented Apr 22, 2016

I don't think the in-place ops (__itruediv__) are handled properly. This should work with the compute happen, then the hanlder that sets inplace called (e.g. in core/ops.py). Also doubt many tests on this.
Of course this will work if the dtype doesn't change. When it changes is the issue.

You are welcome to debug!

@jreback jreback added Bug Difficulty Intermediate Dtype Conversions Unexpected or buggy dtype conversions Numeric Operations Arithmetic, Comparison, and Logical operations labels Apr 22, 2016
@jreback jreback added this to the 0.18.2 milestone Apr 22, 2016
@hhuuggoo
Copy link
Author

oh good point - how should this be handled when the dtype changes?

@jreback
Copy link
Contributor

jreback commented Apr 22, 2016

it should just work, but i don't think the correct methods are being called

@jorisvandenbossche jorisvandenbossche modified the milestones: Next Major Release, 0.19.0 Aug 21, 2016
dkamm pushed a commit to dkamm/pandas that referenced this issue Sep 19, 2017
@jreback jreback modified the milestones: Next Major Release, 0.21.0 Sep 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants