Skip to content

Behavior of numeric ops on Index has changed #8608

Closed
@bryevdv

Description

@bryevdv

The following used to work:

In [7]: import pandas as pd

In [8]: import numpy as np

In [9]: a = np.zeros(5, dtype=np.float)

In [10]: df = pd.DataFrame({"foo": [10, 20, 30, 40, 50]})

In [11]: df.index
Out[11]: Int64Index([0, 1, 2, 3, 4], dtype='int64')

In [12]: df.index * 3.2
Out[12]: Int64Index([0.0, 3.2, 6.4, 9.6, 12.8], dtype='float64')

In [13]: a - df.index * 3.2
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-13-8a6574b7beca> in <module>()
----> 1 a - df.index * 3.2

TypeError: unsupported operand type(s) for -: 'numpy.ndarray' and 'Int64Index'

In [14]: pd.__version__
Out[14]: '0.15.0'

Metadata

Metadata

Assignees

No one assigned

    Labels

    IndexingRelated to indexing on series/frames, not to indexes themselvesRegressionFunctionality that used to work in a prior pandas version

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions