Skip to content

Commit

Permalink
fix(pandas/dask): handle non numpy scalar results in wrap_case_result
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored and gforsyth committed Feb 14, 2023
1 parent 254a0fe commit a3b82f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion ibis/backends/pandas/execution/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,11 @@ def wrap_case_result(raw, expr):
raw_1d, dtype=constants.IBIS_TYPE_TO_PANDAS_TYPE[expr.type()]
)
if result.size == 1 and isinstance(expr, ir.Scalar):
return result.iloc[0].item()
value = result.iloc[0]
try:
return value.item()
except AttributeError:
return value
return result


Expand Down
4 changes: 3 additions & 1 deletion ibis/backends/tests/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,9 @@ def test_array_string_join(con):
assert con.execute(expr) == expected


@pytest.mark.notimpl(["dask", "datafusion", "mssql", "mysql", "pandas", "pyspark"])
@pytest.mark.notimpl(
["datafusion", "mssql", "mysql", "pyspark"], raises=com.OperationNotDefinedError
)
def test_subs_with_re_replace(con):
expr = ibis.literal("hi").re_replace("i", "a").substitute({"d": "b"}, else_="k")
result = con.execute(expr)
Expand Down

0 comments on commit a3b82f7

Please sign in to comment.