Skip to content

Using the python power operator on numerical Index objects yields unexpected results #14973

Closed
@sadruddin

Description

@sadruddin

Code Sample, a copy-pastable example if possible

index = pd.Float64Index(range(1, 11))

expected_pow_values = 2.0**index.values
actual_pow_values = 2.0**index
similar_pow_values = 2.0**np.arange(len(index))

expected_mul_values = 2.0*index.values
actual_mul_values = 2.0*index

other_way_around = index**2.0
same_as = index.values**2.0

Problem description

Using the pow '**' operator on an index object results in a behaviour different than when using the '' operator. The pow result implies that the values being used are not index.values, which one would expect given the behaviour of other operators (, -, +, / ...).
This problem only arises when the index object is the second argument.

Expected Output

expected output would be the result of 2.0**index.values

Output of pd.show_versions()

commit: None
python: 2.7.13.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 42 Stepping 7, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None

pandas: 0.19.1
nose: None
pip: 9.0.1
setuptools: 32.2.0
Cython: None
numpy: 1.12.0rc1
scipy: 0.18.1
statsmodels: 0.8.0rc1
xarray: None
IPython: 5.1.0
sphinx: 1.4.8
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2016.10
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.3
openpyxl: 2.4.1
xlrd: 1.0.0
xlwt: 1.1.2
xlsxwriter: None
lxml: 3.7.0
bs4: None
html5lib: 0.9999999
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNumeric OperationsArithmetic, Comparison, and Logical operations

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions