Skip to content

Modulo (%) operator not supported anymore for Index since 0.15 #9244

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

Closed
jorisvandenbossche opened this issue Jan 13, 2015 · 5 comments
Closed
Labels
API Design Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@jorisvandenbossche
Copy link
Member

In 0.14:

In [1]: pd.__version__
Out[1]: '0.14.1'

In [2]: intidx = pd.Index(range(10))

In [3]: intidx % 2
Out[3]: Int64Index([0, 1, 0, 1, 0, 1, 0, 1, 0, 1], dtype='int64')

now:

In [1]: pd.__version__
Out[1]: '0.15.2'

In [2]: intidx = pd.Index(range(10))

In [3]: intidx % 2
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-de0ac1282c31> in <module>()
----> 1 intidx % 2

TypeError: unsupported operand type(s) for %: 'Int64Index' and 'int'
@jreback
Copy link
Contributor

jreback commented Jan 13, 2015

changeover from ndarray did it.

really what should happen is NumericIndex get these special methods thru core/ops.py (like Series does now).

@jreback jreback added API Design Indexing Related to indexing on series/frames, not to indexes themselves labels Jan 13, 2015
@jreback jreback added this to the 0.16.0 milestone Jan 13, 2015
@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 6, 2015
@nbonnotte
Copy link
Contributor

@jreback I've been looking into this, and into your suggestion, but the thing is that core/ops.py imports pandas.index, so NumericIndex cannot directly get these specials methods from ops.

I'll start with a simple PR with just the definition of NumericIndex.__mod__. That should do it.

@jreback
Copy link
Contributor

jreback commented Dec 29, 2015

this is quite straightforward, just update pandas/core/index.py/Index/_add_numeric_methods

the imports are not an issue

@nbonnotte
Copy link
Contributor

Straightforward indeed, thx!

@jreback jreback modified the milestones: 0.18.0, Next Major Release Jan 11, 2016
@jreback
Copy link
Contributor

jreback commented Jan 14, 2016

closed by #12012

@jreback jreback closed this as completed Jan 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

No branches or pull requests

3 participants