Skip to content

Commit f4ed47a

Browse files
committed
fix for pandas-dev#60695 fix Series constructor dropping key levels when keys have varying entry counts
1 parent 0557c54 commit f4ed47a

File tree

1 file changed

+17
-78
lines changed

1 file changed

+17
-78
lines changed

pandas/core/indexes/multi.py

+17-78
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,65 @@
11
from __future__ import annotations
22

3-
from collections.abc import (
3+
from typing import (
4+
TYPE_CHECKING,
5+
Any,
46
Callable,
57
Collection,
6-
Generator,
78
Hashable,
89
Iterable,
9-
Mapping,
10-
Sequence,
10+
Iterator,
1111
List,
12-
)
13-
from functools import wraps
14-
from sys import getsizeof
15-
from typing import (
16-
TYPE_CHECKING,
17-
Any,
1812
Literal,
13+
Mapping,
14+
Sequence,
1915
cast,
20-
ArrayLike,
16+
overload,
2117
)
22-
import warnings
2318

2419
import numpy as np
2520

26-
from pandas._config import get_option
27-
28-
from pandas._libs import (
29-
algos as libalgos,
30-
index as libindex,
31-
lib,
32-
)
33-
from pandas._libs.hashtable import duplicated
21+
from pandas._libs import lib
22+
from pandas._libs.hashtable import duplicated_int64
3423
from pandas._typing import (
35-
AnyAll,
36-
AnyArrayLike,
24+
ArrayLike,
3725
Axis,
38-
DropKeep,
3926
DtypeObj,
4027
F,
41-
IgnoreRaise,
42-
IndexLabel,
43-
IndexT,
44-
Scalar,
45-
Self,
4628
Shape,
4729
npt,
4830
)
49-
from pandas.compat.numpy import function as nv
50-
from pandas.errors import (
51-
InvalidIndexError,
52-
PerformanceWarning,
53-
UnsortedIndexError,
54-
)
31+
from pandas.errors import InvalidIndexError
5532
from pandas.util._decorators import (
56-
Appender,
5733
cache_readonly,
5834
doc,
59-
set_module,
6035
)
6136
from pandas.util._exceptions import find_stack_level
6237

6338
from pandas.core.dtypes.cast import coerce_indexer_dtype
6439
from pandas.core.dtypes.common import (
6540
ensure_int64,
6641
ensure_platform_int,
67-
is_hashable,
68-
is_integer,
69-
is_iterator,
42+
is_categorical_dtype,
43+
is_extension_array_dtype,
7044
is_list_like,
7145
is_object_dtype,
72-
is_scalar,
73-
is_string_dtype,
7446
pandas_dtype,
7547
)
76-
from pandas.core.dtypes.dtypes import (
77-
CategoricalDtype,
78-
ExtensionDtype,
79-
)
80-
from pandas.core.dtypes.generic import (
81-
ABCDataFrame,
82-
ABCSeries,
83-
)
84-
from pandas.core.dtypes.inference import is_array_like
85-
from pandas.core.dtypes.missing import (
86-
array_equivalent,
87-
isna,
88-
)
48+
from pandas.core.dtypes.dtypes import ExtensionDtype
49+
from pandas.core.dtypes.missing import array_equivalent, isna
8950

9051
import pandas.core.algorithms as algos
91-
from pandas.core.array_algos.putmask import validate_putmask
92-
from pandas.core.arrays import (
93-
Categorical,
94-
ExtensionArray,
95-
)
96-
from pandas.core.arrays.categorical import (
97-
factorize_from_iterables,
98-
recode_for_categories,
99-
)
100-
import pandas.core.common as com
101-
from pandas.core.construction import sanitize_array
102-
import pandas.core.indexes.base as ibase
52+
from pandas.core.arrays.categorical import Categorical
10353
from pandas.core.indexes.base import (
10454
Index,
10555
_index_shared_docs,
10656
ensure_index,
10757
get_unanimous_names,
10858
)
10959
from pandas.core.indexes.frozen import FrozenList
110-
from pandas.core.ops.invalid import make_invalid_op
111-
from pandas.core.sorting import (
112-
get_group_index,
113-
lexsort_indexer,
114-
)
115-
116-
from pandas.io.formats.printing import pprint_thing
11760

11861
if TYPE_CHECKING:
119-
from pandas import (
120-
CategoricalIndex,
121-
DataFrame,
122-
Series,
123-
)
62+
from pandas import DataFrame
12463

12564
_index_doc_kwargs = dict(ibase._index_doc_kwargs)
12665
_index_doc_kwargs.update(

0 commit comments

Comments
 (0)