NVIDIA / NVIDIA/cudf

[BUG] Behavior of __pow__ differs from Pandas for special values

Open
#7,478 4 comments 0 reactions 0 assignees View on GitHub
bug Python
Dominant language
C++
Stars
9.8k
Forks
1.1k
Avg merge
3d 6m
Merged PRs (30d)
278

Description

**Describe the bug**
In pandas, `1** == 1`, whereas in cuDF, `1** == `. Furthermore, in pandas, ` ** 0 == 1` whereas in cuDF, ` ** 0 == `.

**Steps/Code to reproduce bug**

First issue:
```
>>> psr = pd.Series([1,2,3], dtype='int64')
>>> gsr = cudf.Series([1,2,3], dtype='int64')
>>> psr ** pd.NA
0 1
1
2
dtype: object
>>> gsr ** cudf.NA
0
1
2
dtype: int64
```

```
>>> psr = pd.Series([None], dtype='Int64')
>>> gsr = cudf.Series([None], dtype='int64')
>>> psr
0
dtype: Int64
>>> gsr
0
dtype: int64
>>> psr ** 0
0 1
dtype: Int64
>>> gsr ** 0
0
dtype: int64
```

**Expected behavior**
I believe we should match pandas here. Since the behavior we expose here is the behavior of libcudf, we might have to run a few extra kernels to explicitly solve this case.

I believe this is worth doing. It's a tradeoff between extra work that we need to do on the GPU which of course will impact performance, vs the possibility of users running the same data through the same sequence of mathematical operations between pandas and cuDF and getting a different number. IMO the second possibility is more likely to lead to issues on the user side than the first.

**Environment overview (please complete the following information)**
- Environment location: Bare Metal
- Method of cuDF install: Source

**Environment details**
Please run and paste the output of the `cudf/print_env.sh` script here, to gather any other relevant environment details

**Additional context**
Add any other context about the problem here.

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.