From edf3d8aff63d15199205270f8c27b5923f51a51b Mon Sep 17 00:00:00 2001 From: pizza654321 Date: Sun, 30 Jan 2022 20:09:36 -0500 Subject: [PATCH 1/2] Added more uniform 0-level index support --- pandas/core/indexes/multi.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index 7e59e51174b6f..d6d8169e90efa 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -317,8 +317,9 @@ def __new__( raise TypeError("Must pass both levels and codes") if len(levels) != len(codes): raise ValueError("Length of levels and codes must be the same.") - if len(levels) == 0: - raise ValueError("Must pass non-zero number of levels/codes") + # These lines below are inconsistent with behavior elsewhere and can be removed to support 0-level indexes, which should arguably be included + # if len(levels) == 0: + # raise ValueError("Must pass non-zero number of levels/codes") result = object.__new__(cls) result._cache = {} From abf1af545ef8feac46d8927f1fe10dc21312b840 Mon Sep 17 00:00:00 2001 From: pizza654321 Date: Sun, 30 Jan 2022 21:39:55 -0500 Subject: [PATCH 2/2] Fixed line ending problem --- pandas/core/indexes/multi.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index 15c0fce2717df..5df55bf411d47 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -317,7 +317,6 @@ def __new__( raise TypeError("Must pass both levels and codes") if len(levels) != len(codes): raise ValueError("Length of levels and codes must be the same.") - # These lines below are inconsistent with behavior elsewhere and can be removed to support 0-level indexes, which should arguably be included # if len(levels) == 0: # raise ValueError("Must pass non-zero number of levels/codes")