[BUG] After replace [-np.inf, np.inf] with np.nan, group forward fill not working.
- Dominant language
- C++
- Stars
- 9.8k
- Forks
- 1.1k
- Avg merge
- 3d 6m
- Merged PRs (30d)
- 278
Description
**Describe the bug**
There is an inconsistency in the forward fill behavior of cudf when replacing np.inf and -np.inf values using a list. The same operation works correctly with pandas or replace np.inf and -np.inf seperately.
**Steps/Code to reproduce bug**
```
import cudf
import numpy as np
data = {
'group': ['A', 'A', 'A', 'B', 'B', 'B'],
'value': [1, -np.inf, 3, np.inf, 5, np.inf]
}
df = cudf.DataFrame(data)
print("Original DataFrame:")
print(df)
df['value'] = df['value'].replace([-np.inf, np.inf], np.nan)
df['value'] = df.groupby('group')['value'].ffill()
print("\nDataFrame after forward fill:")
print(df)
```
**Output**
> DataFrame after forward fill:
> group value
> 0 A 1.0
> 1 A NaN
> 2 A 3.0
> 3 B NaN
> 4 B 5.0
> 5 B NaN
**Expected behavior**
DataFrame after forward fill:
group value
0 A 1.0
1 A 1.0
2 A 3.0
3 B
4 B 5.0
5 B 5.0
**Environment overview (please complete the following information)**
- Environment location: CentOS
- Method of cuDF install: Conda
it works fine if seperate the replace by:
```
df['value'] = df['value'].replace(-np.inf, np.nan)
df['value'] = df['value'].replace(np.inf, np.nan)
```
or use pandas instead
Contributor guide
Assessment
This issue has not been assessed yet.