Skip to content

BUG: pd.eval against single element array using numexpr engine coerces to scalar #10546

Closed
@sinhrks

Description

@sinhrks
import pandas as pd

# scalar (OK)
s = 1
pd.eval('s', engine='numexpr')
# 1L
pd.eval('s', engine='python')
#1

# array
a = np.array([1])

# OK
pd.eval('a', engine='python')
# array([1])

# NG
pd.eval('a', engine='numexpr')
# 1L

Internally, we can distinguish them using returned shape.

import numexpr as ne
ne.evaluate('s')
# array(1L)
ne.evaluate('a')
# array([1])
ne.evaluate('s').shape
# ()
ne.evaluate('a').shape
# (1,)

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