rapidsai / cudf

cuDF - GPU DataFrame Library
https://docs.rapids.ai/api/cudf/stable/
Apache License 2.0
8.44k stars 903 forks source link

[BUG] index name disappears when indexed with index with single item #12429

Closed bilzard closed 1 year ago

bilzard commented 1 year ago

Describe the bug

Index name disappears when indexed with Index with single item.

Steps/Code to reproduce bug

df = cudf.DataFrame({"id": [1, 2, 3], "key": [3, 4, 5]}).set_index("id")
unique_indexes = df.index.unique()
n_unique = df.index.nunique()
for i in range(0, n_unique, 2):
    idxs = unique_indexes[i : i + 2]
    print(idxs)
    print(df.loc[idxs].to_arrow().to_pandas())

result:

Int64Index([1, 2], dtype='int64', name='id')
    key
id     
1     3
2     4
Int64Index([3], dtype='int64', name='id')
   key
3    5

In the last chunk, index name disappears.

Expected behavior

Index name shouldn't disappear.

Int64Index([1, 2], dtype='int64', name='id')
    key
id     
1     3
2     4
Int64Index([3], dtype='int64', name='id')
   key
id     
3    5

Environment overview (please complete the following information)

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

Click here to see environment details

     **git***
     Not inside a git repository

     ***OS Information***
     DISTRIB_ID=Ubuntu
     DISTRIB_RELEASE=20.04
     DISTRIB_CODENAME=focal
     DISTRIB_DESCRIPTION="Ubuntu 20.04.5 LTS"
     NAME="Ubuntu"
     VERSION="20.04.5 LTS (Focal Fossa)"
     ID=ubuntu
     ID_LIKE=debian
     PRETTY_NAME="Ubuntu 20.04.5 LTS"
     VERSION_ID="20.04"
     HOME_URL="https://www.ubuntu.com/"
     SUPPORT_URL="https://help.ubuntu.com/"
     BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
     PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
     VERSION_CODENAME=focal
     UBUNTU_CODENAME=focal
     Linux 3a80ee54d79e 5.15.0-56-generic #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

     ***GPU Information***
     Thu Dec 22 06:35:09 2022
     +-----------------------------------------------------------------------------+
     | NVIDIA-SMI 520.61.05    Driver Version: 520.61.05    CUDA Version: 11.8     |
     |-------------------------------+----------------------+----------------------+
     | GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
     | Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
     |                               |                      |               MIG M. |
     |===============================+======================+======================|
     |   0  NVIDIA GeForce ...  On   | 00000000:01:00.0 Off |                  Off |
     |  0%   41C    P8    30W / 450W |    589MiB / 24564MiB |      0%      Default |
     |                               |                      |                  N/A |
     +-------------------------------+----------------------+----------------------+

     +-----------------------------------------------------------------------------+
     | Processes:                                                                  |
     |  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
     |        ID   ID                                                   Usage      |
     |=============================================================================|
     +-----------------------------------------------------------------------------+

     ***CPU***
     Architecture:                    x86_64
     CPU op-mode(s):                  32-bit, 64-bit
     Byte Order:                      Little Endian
     Address sizes:                   46 bits physical, 48 bits virtual
     CPU(s):                          24
     On-line CPU(s) list:             0-23
     Thread(s) per core:              1
     Core(s) per socket:              16
     Socket(s):                       1
     NUMA node(s):                    1
     Vendor ID:                       GenuineIntel
     CPU family:                      6
     Model:                           151
     Model name:                      12th Gen Intel(R) Core(TM) i9-12900K
     Stepping:                        2
     CPU MHz:                         3200.000
     CPU max MHz:                     4020.0000
     CPU min MHz:                     800.0000
     BogoMIPS:                        6374.40
     Virtualization:                  VT-x
     L1d cache:                       384 KiB
     L1i cache:                       256 KiB
     L2 cache:                        10 MiB
     NUMA node0 CPU(s):               0-23
     Vulnerability Itlb multihit:     Not affected
     Vulnerability L1tf:              Not affected
     Vulnerability Mds:               Not affected
     Vulnerability Meltdown:          Not affected
     Vulnerability Mmio stale data:   Not affected
     Vulnerability Retbleed:          Not affected
     Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
     Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user pointer sanitization
     Vulnerability Spectre v2:        Mitigation; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence
     Vulnerability Srbds:             Not affected
     Vulnerability Tsx async abort:   Not affected
     Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb intel_pt sha_ni xsaveopt xsavec xgetbv1 xsaves split_lock_detect avx_vnni dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req umip pku ospke waitpkg gfni vaes vpclmulqdq tme rdpid movdiri movdir64b fsrm md_clear serialize pconfig arch_lbr flush_l1d arch_capabilities

     ***CMake***
     /usr/local/bin/cmake
     cmake version 3.24.3

     CMake suite maintained and supported by Kitware (kitware.com/cmake).

     ***g++***
     /usr/bin/g++
     g++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
     Copyright (C) 2019 Free Software Foundation, Inc.
     This is free software; see the source for copying conditions.  There is NO
     warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

     ***nvcc***
     /usr/local/cuda/bin/nvcc
     nvcc: NVIDIA (R) Cuda compiler driver
     Copyright (c) 2005-2022 NVIDIA Corporation
     Built on Wed_Jun__8_16:49:14_PDT_2022
     Cuda compilation tools, release 11.7, V11.7.99
     Build cuda_11.7.r11.7/compiler.31442593_0

     ***Python***
     /usr/bin/python
     Python 3.8.10

     ***Environment Variables***
     PATH                            : /root/.vscode-server/bin/e8a3071ea4344d9d48ef8a4df2c097372b0c5161/bin/remote-cli:/opt/tritonserver/bin:/usr/local/cuda/lib64/:/usr/local/mpi/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/ucx/bin:/usr/local/cuda/bin:
     LD_LIBRARY_PATH                 : /usr/local/cuda/compat/lib:/usr/local/nvidia/lib:/usr/local/nvidia/lib64:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64:/usr/local/lib:/repos/dist/lib:/opt/tritonserver/lib
     NUMBAPRO_NVVM                   :
     NUMBAPRO_LIBDEVICE              :
     CONDA_PREFIX                    :
     PYTHON_PATH                     :

     conda not found
     ***pip packages***
     /usr/local/bin/pip
     Package                   Version
     ------------------------- --------------------
     absl-py                   1.3.0
     aiohttp                   3.8.3
     aiosignal                 1.3.1
     alembic                   1.8.1
     ansi2html                 1.8.0
     anyio                     3.6.2
     argon2-cffi               21.3.0
     argon2-cffi-bindings      21.2.0
     asttokens                 2.1.0
     asvdb                     0.4.2
     async-timeout             4.0.2
     attrs                     22.1.0
     autopage                  0.5.1
     Babel                     2.11.0
     backcall                  0.2.0
     beautifulsoup4            4.11.1
     betterproto               1.2.5
     black                     23.1a1
     bleach                    5.0.1
     bokeh                     2.4.3
     boto3                     1.26.15
     botocore                  1.29.15
     Brotli                    1.0.9
     cachetools                5.2.0
     certifi                   2019.11.28
     cffi                      1.15.1
     chardet                   3.0.4
     charset-normalizer        2.1.1
     click                     8.1.3
     cliff                     4.1.0
     cloudpickle               2.2.0
     cmaes                     0.9.0
     cmake                     3.24.3
     cmd2                      2.4.2
     colorlog                  6.7.0
     contourpy                 1.0.6
     cuda-python               11.8.1
     cupy-cuda117              10.6.0
     cycler                    0.11.0
     Cython                    0.29.32
     dash                      2.7.1
     dash-core-components      2.0.0
     dash-html-components      2.0.0
     dash-table                5.0.0
     dask                      2022.11.1
     dask-cuda                 22.12.0
     dbus-python               1.2.16
     debugpy                   1.6.3
     decorator                 5.1.1
     defusedxml                0.7.1
     distributed               2022.11.1
     distro                    1.8.0
     docker-pycreds            0.4.0
     entrypoints               0.4
     exceptiongroup            1.0.4
     executing                 1.2.0
     faiss                     1.7.2
     fastai                    2.7.10
     fastcore                  1.5.27
     fastdownload              0.0.7
     fastjsonschema            2.16.2
     fastprogress              1.0.3
     fastrlock                 0.8.1
     fiddle                    0.2.5
     filelock                  3.8.0
     Flask                     2.2.2
     fonttools                 4.38.0
     frozenlist                1.3.3
     fsspec                    2022.5.0
     gevent                    22.10.2
     geventhttpclient          2.0.2
     gitdb                     4.0.9
     GitPython                 3.1.29
     googleapis-common-protos  1.57.0
     graphviz                  0.20.1
     greenlet                  2.0.1
     grpcio                    1.41.0
     grpcio-channelz           1.50.0
     grpclib                   0.4.3
     h2                        4.1.0
     HeapDict                  1.0.1
     hpack                     4.0.0
     huggingface-hub           0.11.0
     hyperframe                6.0.1
     idna                      2.8
     implicit                  0.6.1
     importlib-metadata        4.13.0
     importlib-resources       5.10.0
     iniconfig                 1.1.1
     IProgress                 0.4
     ipykernel                 6.17.1
     ipython                   8.6.0
     ipython-genutils          0.2.0
     ipywidgets                8.0.3
     itsdangerous              2.1.2
     japanize-matplotlib       1.1.3
     jedi                      0.18.2
     Jinja2                    3.1.2
     jmespath                  1.0.1
     joblib                    1.2.0
     json5                     0.9.10
     jsonschema                4.17.1
     jupyter_client            7.3.5
     jupyter_core              5.0.0
     jupyter-dash              0.4.2
     jupyter-server            1.23.3
     jupyterlab                3.4.6
     jupyterlab-materialdarker 0.6.1
     jupyterlab-pygments       0.2.2
     jupyterlab_server         2.16.3
     jupyterlab-widgets        3.0.4
     kiwisolver                1.4.4
     libcst                    0.4.9
     lightfm                   1.16
     lightgbm                  3.3.3
     llvmlite                  0.39.1
     locket                    1.0.0
     Mako                      1.2.4
     MarkupSafe                2.1.1
     matplotlib                3.6.2
     matplotlib-inline         0.1.6
     merlin-core               0.9.0
     merlin-dataloader         0.0.3
     merlin-models             0.10.0
     merlin-systems            0.8.0
     mistune                   2.0.4
     msgpack                   1.0.4
     multidict                 6.0.2
     mypy-extensions           0.4.3
     nb-black                  1.0.7
     nbclassic                 0.4.8
     nbclient                  0.7.0
     nbconvert                 7.2.5
     nbformat                  5.7.0
     nest-asyncio              1.5.6
     ninja                     1.11.1
     notebook                  6.5.2
     notebook_shim             0.2.2
     npy-append-array          0.9.13
     numba                     0.56.4
     numpy                     1.22.4
     nvidia-pyindex            1.0.9
     nvtabular                 1.7.0
     nvtx                      0.2.5
     oldest-supported-numpy    2022.11.19
     optuna                    3.0.3
     packaging                 21.3
     pandas                    1.3.5
     pandocfilters             1.5.0
     parso                     0.8.3
     partd                     1.3.0
     pathspec                  0.10.3
     pathtools                 0.1.2
     pbr                       5.11.0
     pexpect                   4.8.0
     pickleshare               0.7.5
     Pillow                    9.3.0
     pip                       22.3.1
     pkgutil_resolve_name      1.3.10
     platformdirs              2.5.4
     plotly                    5.11.0
     pluggy                    1.0.0
     polars                    0.15.7
     prettytable               3.5.0
     prometheus-client         0.15.0
     promise                   2.3
     prompt-toolkit            3.0.33
     protobuf                  3.19.6
     psutil                    5.9.4
     ptyprocess                0.7.0
     pure-eval                 0.2.2
     pyarrow                   7.0.0
     pybind11                  2.10.1
     pycparser                 2.21
     pydot                     1.4.2
     Pygments                  2.13.0
     PyGObject                 3.36.0
     pynvml                    11.4.1
     pyparsing                 3.0.9
     pyperclip                 1.8.2
     pyrsistent                0.19.2
     pytest                    7.2.0
     python-apt                2.0.0+ubuntu0.20.4.8
     python-dateutil           2.8.2
     python-rapidjson          1.9
     pytz                      2022.6
     PyYAML                    6.0
     pyzmq                     24.0.1
     regex                     2022.10.31
     requests                  2.28.1
     requests-unixsocket       0.2.0
     retrying                  1.3.4
     s3transfer                0.6.0
     sacremoses                0.0.53
     scikit-build              0.16.2
     scikit-learn              1.1.3
     scipy                     1.8.1
     seaborn                   0.12.1
     Send2Trash                1.8.0
     sentry-sdk                1.11.1
     setproctitle              1.3.2
     setuptools                45.2.0
     setuptools-scm            7.0.5
     shortuuid                 1.0.11
     six                       1.14.0
     sklearn                   0.0.post1
     smmap                     5.0.0
     sniffio                   1.3.0
     sortedcontainers          2.4.0
     soupsieve                 2.3.2.post1
     SQLAlchemy                1.4.44
     stack-data                0.6.1
     stevedore                 4.1.1
     stringcase                1.2.0
     tblib                     1.7.0
     tenacity                  8.1.0
     tensorflow-metadata       1.11.0
     terminado                 0.17.0
     testbook                  0.4.2
     threadpoolctl             3.1.0
     tinycss2                  1.2.1
     tokenizers                0.10.3
     tomli                     2.0.1
     toolz                     0.12.0
     torch                     1.13.0
     torchinfo                 1.7.1
     torchmetrics              0.10.3
     tornado                   6.2
     tqdm                      4.64.1
     traitlets                 5.5.0
     transformers              4.12.0
     transformers4rec          0.1.15
     treelite                  2.3.0
     treelite-runtime          2.3.0
     tritonclient              2.28.0
     typing_extensions         4.4.0
     typing-inspect            0.8.0
     urllib3                   1.26.12
     wandb                     0.13.5
     wcwidth                   0.2.5
     webencodings              0.5.1
     websocket-client          1.4.2
     Werkzeug                  2.2.2
     wheel                     0.34.2
     widgetsnbextension        4.0.4
     xgboost                   1.6.2
     yarl                      1.8.1
     zict                      2.2.0
     zipp                      3.10.0
     zope.event                4.5.0
     zope.interface            5.5.2

Additional context

cudf.__version__
'22.06.00a+319.g97422602b8'
GregoryKimball commented 1 year ago

Thank you @bilzard for sharing this issue. I tested your repro on cuDF 22.06 and 22.10. I see the index name drop on 22.06 and see that it is preserved on 22.10. I recommend rolling forward to a newer cuDF version.

bilzard commented 1 year ago

@GregoryKimball Thank you for checking. I also confirmed 22.10 solved the issue. So, does’t this repository support bug fix of non-latest versions? Perhaps some people might not able to upgrade to the latest version because of environment compatibilities etc.

beckernick commented 1 year ago

The engineering effort required to backport every bug fix to prior versions is enormous, making it unfeasible to do this in the general case.

We understand that organizations and platforms often have complex environment dependencies or restrictions that can sometimes make it challenging to update to the newest version. As part of the NVIDIA AI Enteprise commercial offering, cuDF v21.08 was designated as long-term support for critical bugfixes and security issues. If your organization is interested in this kind of enterprise support, you can learn more about NVAIE in general in the above link or about Support Services here.

bilzard commented 1 year ago

@beckernick I see. Thank you for the information. Closing issue.