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

BUG/API Series/Index integer floordiv/mod inconsistency #13843

Closed
sinhrks opened this issue Jul 29, 2016 · 3 comments · Fixed by #27321
Closed

BUG/API Series/Index integer floordiv/mod inconsistency #13843

sinhrks opened this issue Jul 29, 2016 · 3 comments · Fixed by #27321
Assignees
Labels
Bug Numeric Operations Arithmetic, Comparison, and Logical operations
Milestone

Comments

@sinhrks
Copy link
Member

sinhrks commented Jul 29, 2016

Series looks to be coerced to float if the result contains NaN or inf. Otherwise Index doesn't. Make it to be consistent in either way.

Code Sample, a copy-pastable example if possible

pd.Series([1]) // pd.Series([0])
#0    inf
# dtype: float64

pd.Index([1]) // pd.Index([0])
# Int64Index([0], dtype='int64')

np.array([1]) // np.array([0])
# array([0])
pd.Series([1]) % pd.Series([0])
#0   NaN
# dtype: float64

pd.Index([1]) % pd.Index([0])
# Int64Index([0], dtype='int64')

np.array([1]) % np.array([0])
# array([0])

output of pd.show_versions()

on current master.

@sinhrks sinhrks added Bug Numeric Operations Arithmetic, Comparison, and Logical operations labels Jul 29, 2016
@sinhrks sinhrks added this to the 0.19.0 milestone Jul 29, 2016
@jreback
Copy link
Contributor

jreback commented Jul 29, 2016

this was set this way a while ago - Index should be the same

numpy is wrong as it doesn't coerce types

@sinhrks
Copy link
Member Author

sinhrks commented Jul 29, 2016

OK. Found inconsistencies between int/float Series also. Both should be inf as the same as truediv?

np.__version__
# '1.11.1'

# OK
pd.Series([4]) // pd.Series([0])
# 0    inf
# dtype: float64

# NG
pd.Series([4.]) // pd.Series([0.])
# 0   NaN
# dtype: float64

# truediv, OK
# pd.Series([4.]) / pd.Series([0.])
# 0    inf
# dtype: float64

@jorisvandenbossche jorisvandenbossche modified the milestones: 0.20.0, 0.19.0 Sep 1, 2016
@jreback jreback modified the milestones: 0.20.0, Next Major Release Mar 23, 2017
@jbrockmendel
Copy link
Member

Added to the TODO list in #18824. FWIW all of the examples above except for pd.Series([4.]) // pd.Series([0.]) have been fixed.

@jbrockmendel jbrockmendel self-assigned this Jan 28, 2019
@jreback jreback modified the milestones: Contributions Welcome, 0.25.0 Jul 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants