rapidsai / cudf

cuDF - GPU DataFrame Library
https://docs.rapids.ai/api/cudf/stable/
Apache License 2.0
8.38k stars 896 forks source link

[FEA] AST expression was provided non-matching operand types #12319

Open mattf opened 1 year ago

mattf commented 1 year ago

Is your feature request related to a problem? Please describe. rewriting pandas code with import cudf as pd

Describe the solution you'd like

>>> import pandas as pd
>>> import cudf
>>> cudf.__version__
'22.10.01+2.gca9a422da9' <- rapidsai/rapidsai-nightly:cuda11.5-runtime-centos7-py3.9 (3b7d5d24867a) on 6 dec 2022
>>> df = cudf.DataFrame({'a': [1,2,3], 'b': [3.0,2.0,1.0]})
>>> df.to_pandas().eval('a + b')
0    4.0
1    4.0
2    4.0
dtype: float64
>>> df.eval('a + b')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/conda/envs/rapids/lib/python3.9/contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "/opt/conda/envs/rapids/lib/python3.9/site-packages/cudf/core/dataframe.py", line 6766, in eval
    None: libcudf.transform.compute_column(
  File "transform.pyx", line 190, in cudf._lib.transform.compute_column
RuntimeError: cuDF failure at: /workspace/.conda-bld/work/cpp/src/ast/expression_parser.cpp:149: An AST expression was provided non-matching operand types.

same behavior as pandas

vyasr commented 1 year ago

This is a known and documented behavior, we do not currently support automatic casting of types. I just realized that the documentation for eval was not being published, I've opened a PR to fix that.

mattf commented 1 year ago

update to FEA from BUG