[BUG] cudf.pivot_table behavior does not match pandas.pivot_table - mismatched index structure
- Dominant language
- C++
- Stars
- 9.8k
- Forks
- 1.1k
- Avg merge
- 3d 6m
- Merged PRs (30d)
- 278
Description
**Describe the bug**
working with `import cudf as pd`
**Steps/Code to reproduce bug**
```
In [1]: import cudf as pd
In [2]: pd.__version__
Out[2]: '22.12.00'
In [3]: df = pd.DataFrame({"A": ["foo", "foo", "foo", "foo", "foo",
...: "bar", "bar", "bar", "bar"],
...: "B": ["one", "one", "one", "two", "two",
...: "one", "one", "two", "two"],
...: "C": ["small", "large", "large", "small",
...: "small", "large", "small", "small",
...: "large"],
...: "D": [1, 2, 2, 3, 3, 4, 5, 6, 7],
...: "E": [2, 4, 5, 5, 6, 6, 8, 9, 9]})
In [4]: df
Out[4]:
A B C D E
0 foo one small 1 2
1 foo one large 2 4
2 foo one large 2 5
3 foo two small 3 5
4 foo two small 3 6
5 bar one large 4 6
6 bar one small 5 8
7 bar two small 6 9
8 bar two large 7 9
In [5]: pd.pivot_table(df, index=["A"], columns=["B"], aggfunc="size", fill_value=0)
Out[5]:
C D E
B one two one two one two
A
bar 2 2 2 2 2 2
foo 3 2 3 2 3 2
In [6]: import pandas
In [7]: pandas.__version__
Out[7]: '1.5.2'
In [8]: pandas.pivot_table(df.to_pandas(), index=["A"], columns=["B"], aggfunc="size", fill_value=0)
Out[8]:
B one two
A
bar 2 2
foo 3 2
```
Contributor guide
Assessment
This issue has not been assessed yet.