NVIDIA / NVIDIA/cudf

[FEA] DataFrame.query support for strings

Open
#12,508 0 comments 0 reactions 0 assignees View on GitHub
0 - Backlog feature request Python
Dominant language
C++
Stars
9.8k
Forks
1.1k
Avg merge
3d 6m
Merged PRs (30d)
278

Description

**Is your feature request related to a problem? Please describe.**
working with code using `import cudf as pd`

**Describe the solution you'd like**
functionality matching `import pandas as pd`
```
In [1]: import cudf as pd

In [2]: df = pd.DataFrame({'a': ['one', 'two', 'three']})

In [3]: df.query('a == "one"')
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In [3], line 1
----> 1 df.query('a == "one"')

File ~/.local/lib/python3.9/site-packages/cudf/core/dataframe.py:4174, in DataFrame.query(self, expr, local_dict)
4168 callenv = {
4169 "locals": callframe.f_locals,
4170 "globals": callframe.f_globals,
4171 "local_dict": local_dict,
4172 }
4173 # Run query
-> 4174 boolmask = queryutils.query_execute(self, expr, callenv)
4175 return self._apply_boolean_mask(boolmask)

File ~/.local/lib/python3.9/site-packages/cudf/utils/queryutils.py:218, in query_execute(df, expr, callenv)
216 # wait to check the types until we know which cols are used
217 if any(col.dtype not in SUPPORTED_QUERY_TYPES for col in colarrays):
--> 218 raise TypeError(
219 "query only supports numeric, datetime, timedelta, "
220 "or bool dtypes."
221 )
223 colarrays = [col.data_array_view for col in colarrays]
225 kernel = compiled["kernel"]

TypeError: query only supports numeric, datetime, timedelta, or bool dtypes.

In [4]: pd.__version__
Out[4]: '22.12.0'

In [5]: df.to_pandas().query('a == "one"')
Out[5]:
a
0 one
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.