NVIDIA / NVIDIA/cudf

[BUG] cudf.from_pandas unnecessarily sorts incoming MultiIndex levels

Open
#14,007 2 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**
cudf.from_pandas unnecessarily sorts incoming MultiIndex levels

**Steps/Code to reproduce bug**
```python
In [1]: import cudf

In [2]: mi = cudf.MultiIndex.from_tuples([("a", "b"), ("c", "d")])

In [4]: import pandas

In [5]: mi = pandas.MultiIndex.from_tuples([("e", "f"), ("c", "d")])

In [6]: new_mi = mi.insert(0, ("a", "b"))

In [7]: new_mi.levels[0]
Out[7]: Index(['c', 'e', 'a'], dtype='object')

In [8]: cudf.from_pandas(new_mi).levels[0]
Out[8]: StringIndex(['a' 'e' 'c'], dtype='object', name=0)
```

**Expected behavior**
Not sure if there's a specific reason why cudf needs to sort the levels or if there are any subsequent behaviors dependent on sorting, but it would be great if level order was preserved. This could be gated behind `mode.pandas_compatible`

**Environment overview (please complete the following information)**
- Environment location: Bare-metal
- Method of cuDF install: conda
- If method of install is [Docker], provide `docker pull` & `docker run` commands used

**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.