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

Closed
jorisvandenbossche opened this Issue Jan 13, 2015 · 5 comments

Comments

Projects
None yet
3 participants

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'
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 added this to the 0.16.0 milestone Jan 13, 2015

@jreback jreback modified the milestone: 0.16.0, Next Major Release Mar 6, 2015

Contributor

nbonnotte commented Dec 29, 2015

@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.

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

Contributor

nbonnotte commented Jan 10, 2016

Straightforward indeed, thx!

@jreback jreback modified the milestone: 0.18.0, Next Major Release Jan 11, 2016

Contributor

jreback commented Jan 14, 2016

closed by #12012

jreback closed this Jan 14, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment