Skip to content

API: MultiIndex attributes return tuple instead of FrozenList #53582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 124 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
ceb609d
API: MultiIndex attributes return tuple instead of FrozenList
mroeschke Jun 9, 2023
63f6d46
Fix more tests
mroeschke Jun 12, 2023
06514f9
fix doctests, typing
mroeschke Jun 13, 2023
00b76c7
Fix more doctests
mroeschke Jun 13, 2023
7d695a0
Add typing
mroeschke Jun 14, 2023
ada0c74
Change to tuple[Index]
mroeschke Jun 14, 2023
fc13279
Remove use of difference
mroeschke Jun 14, 2023
149236a
Only label as tuple
mroeschke Jun 14, 2023
2cbeea7
Fix more typing
mroeschke Jun 15, 2023
4dcb731
RLS: 2.1.0rc0 (#54501)
lithomas1 Aug 11, 2023
651bd7b
Start 2.2.0 (#54502)
lithomas1 Aug 11, 2023
3edf7e0
Merge branch 'main' into api/multi/tuple
mroeschke Aug 25, 2023
a9cf640
CI: Pin more cython (#54759)
lithomas1 Aug 26, 2023
a47a4a8
Revert deprecation of con as keyword only arg (#54750)
phofl Aug 26, 2023
8e3963b
Use NaN as na_value for new pyarrow_numpy StringDtype (#54585)
phofl Aug 26, 2023
267512f
Fix roundtripping with pyarrow schema (#54768)
phofl Aug 26, 2023
04ff46f
BUG: merge raising for ea int and numpy float (#54755)
phofl Aug 26, 2023
829318f
PERF: Increase threashold for using binary search in IndexEngine (#54…
l3robot Aug 26, 2023
e7805ea
CI: Remove strict option (#54783)
lithomas1 Aug 27, 2023
8bcc190
BUG: Special-case setting nan into integer series (#54527)
MarcoGorelli Aug 28, 2023
4e1d155
WARN: Remove non-actionable warning in value_counts (#54789)
phofl Aug 28, 2023
5536671
Implement any and all for pyarrow numpy strings (#54591)
phofl Aug 28, 2023
4768051
MAINT: small simplification of meson.build following best practices (…
dnicolodi Aug 28, 2023
d84e97b
DOC: fix formatting in .at docstring (#54730)
SaraBonati Aug 28, 2023
16646fc
ExtensionArray.fillna: start with DeprecationWarning about added copy…
jorisvandenbossche Aug 28, 2023
fff5814
REGR: Index.union loses python string dtype (#54778)
phofl Aug 28, 2023
54da73d
DOC: update docstrings for ffill and bfill (no longer aliases for fil…
jorisvandenbossche Aug 28, 2023
bd00055
PERF: skip libjoin fastpath for MultiIndex (#54765)
lukemanley Aug 28, 2023
8dc47ad
BUG: repr aligning left for string dtype columns (#54801)
phofl Aug 28, 2023
54b47e2
Revert "MAINT: small simplification of meson.build following best pra…
phofl Aug 28, 2023
8f4080d
Fix minor cython warning (#54816)
mroeschke Aug 28, 2023
41403dd
REF: Dispatch ArrowExtensionArray.fillna methods to pad_or_backfill (…
mroeschke Aug 28, 2023
4b4a2a1
REGR: clip raising for list-bound (#54823)
phofl Aug 28, 2023
5e681c1
Infer string storage based on infer_string option (#54794)
phofl Aug 29, 2023
bee0b68
DOC: Added missing git instruction to docs on how to update environme…
DeaMariaLeon Aug 29, 2023
b90a8fb
DEP: Deprecate passing fill_value and freq to shift (#54818)
phofl Aug 29, 2023
866dc08
DEPR: deprecate strings T, S, L, U, and N in offsets frequencies, re…
natmokval Aug 29, 2023
49f6442
Don't expose EA.pad_or_backfill to users + switch to DeprecationWarni…
jorisvandenbossche Aug 29, 2023
79bca17
DOC: added docstring for `storage_options` in `read_html` (#54815)
rsm-23 Aug 29, 2023
daa39d0
ERR: improve setitem error message for DatetimeArray (#54809)
jorisvandenbossche Aug 29, 2023
4b656d5
TYP: Added type hint to Index.repeat (#54739)
mecopur Aug 29, 2023
43c67d2
DOC issue 54822: per @DavidToneian recommendation, I used a specific …
idealcrouch Aug 29, 2023
2b9dba7
BUG: ArrowExtensionArray.factorize with chunked dictionary array (#54…
mroeschke Aug 29, 2023
ca30ba2
DOC: Add date for v2.1.0 (#54850)
lithomas1 Aug 29, 2023
7d97399
DOC: update information of parameter value_name of pandas.melt (#54828)
thiagogquinto Aug 30, 2023
ad68e76
DOC: Add note about using conda to generate debug builds (#54860)
WillAyd Aug 30, 2023
a690ab8
PERF: lexsort_indexer (MultiIndex / multi-column sorting) (#54835)
lukemanley Aug 30, 2023
73c1d5f
Fix GH #54853: BUG: DeprecationWarning for frontend.OptionParser when…
DavidToneian Aug 30, 2023
c4b1312
DOC: fix a typo in development doc (#54886)
xzmeng Aug 31, 2023
99aa4b6
WEB: Add 2.1 to the switcher (#54874)
lithomas1 Aug 31, 2023
d1dd8e0
WEB: fix 2.1 url in versions.json (#54890)
jorisvandenbossche Aug 31, 2023
a53f896
DOC: Add release notes for 2.1.1 (#54879)
lukemanley Aug 31, 2023
b2a0a24
REGR: setitem with part of a MultiIndex raises (#54885)
lukemanley Aug 31, 2023
843c247
CI: add empty line in `no-bool-in-generic` to avoid `black` complaini…
Charlie-XIAO Aug 31, 2023
6555997
MAINT: Reflect changes from `numpy` namespace refactor Part 5 (#54894)
mtsokol Aug 31, 2023
6a8e899
Update warning message for consistency (#54893)
paulpellissiercompass Aug 31, 2023
ac18ef0
PERF: sort_index with an already monotonic MultiIndex (#54883)
lukemanley Aug 31, 2023
6cc880c
TYP: simple return types (#54786)
mroeschke Sep 11, 2023
8161505
DOC: updated docstring for deprecation of axis=1 in groupby (#54896)
rsm-23 Aug 31, 2023
3c2ccc1
TST: added test with missing categories for `value_counts` (#54837)
rsm-23 Aug 31, 2023
69e5794
REGR: read_csv raising when dtypes is specified with usecols (#54881)
phofl Sep 1, 2023
385b69e
ENH: allow EADtype to specify _supports_2d (#54832)
jbrockmendel Sep 1, 2023
8d0e7bc
DEPR: downcasting in NDFrame.where, mask, clip (#53656)
jbrockmendel Sep 1, 2023
6dd8b3d
REGR: comparing datetime vs None raises (#54880)
phofl Sep 1, 2023
5d1bf0d
REGR: get_group raising with axis=1 (#54882)
phofl Sep 1, 2023
bbede50
REGR: value_counts raises with bins (#54884)
phofl Sep 1, 2023
2557e68
REGR: Merge raising when left merging on arrow string index (#54895)
phofl Sep 1, 2023
d71c2c2
#50990 Increase to_dict('list') performance (#54824)
taytzehao Sep 1, 2023
563fa95
BUG: ArrowExtensionArray.to_numpy avoid object dtype when na_value pr…
lukemanley Sep 1, 2023
9ee3942
DOC: add missing periods in JSON section (#54924)
JohannaTrost Sep 1, 2023
37aefa2
REF: cast x and bins to Index early in cut, qcut (#54919)
jbrockmendel Sep 1, 2023
72727ee
DOC: fixes Sphinx parallel build error on `doc/source/whatsnew/v0.24.…
JohannaTrost Sep 1, 2023
f819a9a
REGR: drop_duplicates raising for arrow strings (#54913)
phofl Sep 2, 2023
582bf05
BLD: Fix race condition (#54958)
lithomas1 Sep 2, 2023
b38ad40
REGR: read_csv splitting on comma with delim_whitespace (#54954)
phofl Sep 2, 2023
ea504a4
REGR: MultiIndex.append raising for overlapping IntervalIndex levels …
lukemanley Sep 2, 2023
911a0f1
Infer large_string type as pyarrow_numpy strings (#54826)
phofl Sep 2, 2023
c3f97ef
BUG: DataFrame.stack with future_stack=True failing when columns are …
rhshadrach Sep 2, 2023
10738de
BUG: Categorical.isin raising for overlapping intervals (#54951)
lukemanley Sep 2, 2023
ae45b9b
new pandas cheat sheet fomats (#54928)
fralfaro Sep 3, 2023
988603c
REGR: rountripping datetime through sqlite doesn't work (#54985)
phofl Sep 4, 2023
b06ee4b
DOC: fix an example in whatsnew/v0.15.2.rst (#54986)
natmokval Sep 4, 2023
2e2d9d7
TYP: Add typing.overload signatures to DataFrame/Series.interpolate (…
caneff Sep 4, 2023
f16e1ed
TYP: Add typing.overload signatures to DataFrame/Series.clip (#55002)
caneff Sep 4, 2023
fcc957a
[pre-commit.ci] pre-commit autoupdate (#55004)
pre-commit-ci[bot] Sep 4, 2023
ac464bc
BUG: ArrowDtype raising for fixed size list (#55000)
phofl Sep 5, 2023
c8e1ad3
DOC: Grammatically updated the tech docs (#54989)
mhb143 Sep 5, 2023
a09859a
DOC: expanded pandas.DataFrame.to_sql docstring (#54988)
pauluhlenbruck Sep 5, 2023
d0cc133
ENH: Use more arrow compute functions for string[pyarrow] dtype (#54957)
phofl Sep 5, 2023
1a4d3ad
REGR: interpolate raising if fill_value is given (#54927)
phofl Sep 5, 2023
04c7291
BUG: Fix Rolling where duplicate datetimelike indexes are treated as …
ihsansecer Sep 5, 2023
ff99f88
REGR: concat raising for 2 different ea dtypes (#54914)
phofl Sep 5, 2023
c268ed4
CI: Ignore hypothesis differing executors (#55013)
mroeschke Sep 5, 2023
a83511f
Include pyarrow_numpy string in efficient merge implementation (#54974)
phofl Sep 5, 2023
0b87076
REG: filter not respecting the order of labels (#54982)
phofl Sep 5, 2023
5139e84
Enable Arrow implementation for removeprefix (#54972)
phofl Sep 6, 2023
0deadef
BUG: merge with left and/or right empty returning mis-ordered columns…
lukemanley Sep 6, 2023
d7a203d
TYP: fix a few types (#54976)
twoertwein Sep 6, 2023
8d62fb0
TST: add test case of ngroup with NaN value (#54966)
josemayer Sep 6, 2023
88861c6
TST: Use (unused) window parameter of test_freq_window_not_implemente…
ihsansecer Sep 6, 2023
c804914
DOC: Add missing word to `IndexOpsMixin.array` docstring (#55034)
dpoznik Sep 6, 2023
f863469
TST: Use more explicit object names (#55033)
mroeschke Sep 6, 2023
eb637dc
BUG: pct_change showing unnecessary FutureWarning (#54983)
phofl Sep 6, 2023
a959b19
ENH: Implement more string accessors through PyArrow (#54960)
phofl Sep 6, 2023
6acf643
DEPR: DataFrameGroupBy.apply operating on the group keys (#54950)
rhshadrach Sep 7, 2023
0774ecd
Improve error message for StringDtype with invalid storage (#55052)
phofl Sep 7, 2023
29a9ab4
Fix pickle roundtrip for new arrow string dtype (#55051)
phofl Sep 7, 2023
5524d8a
Fix docstring of Index.join in base.py (#55050)
kmuehlbauer Sep 7, 2023
6654daf
BLD: Build wheels for Python 3.12 (#55010)
lithomas1 Sep 7, 2023
5d8aa70
Convert test_sql to pytest idiom (#54936)
WillAyd Sep 7, 2023
836e7fe
REGR: DataFrameGroupBy.agg with duplicate column names and a dict (#5…
rhshadrach Sep 7, 2023
7ae516a
BLD: improvements to meson.build files (#54949)
rgommers Sep 8, 2023
3a3adbf
Add TODO note to BlockManager.fast_xs for EA dtypes (#55039)
lukemanley Sep 8, 2023
af7b504
ENH: use shutil.which() instead of external which(1) (#54937)
mgorny Sep 8, 2023
524be40
BUG: read_csv(on_bad_lines='warn') did not raise a Python warning (#5…
mroeschke Sep 8, 2023
4815e03
COMPAT: bump pyarrow min version for div on duration (#55048)
bnavigator Sep 8, 2023
29d346d
TYP/DOC: fix flavor param with incorrect type hint in read_html (#55076)
matheusfelipeog Sep 9, 2023
313758d
Bump actions/checkout from 3 to 4 (#55086)
dependabot[bot] Sep 11, 2023
e2f11e1
BUG: concat(axis=1) ignoring sort parameter for DatetimeIndex (#55085)
lukemanley Sep 11, 2023
50cb682
PERF: concat(axis=1) with unaligned indexes (#55084)
lukemanley Sep 11, 2023
0305571
TYP: Misc type corrections (#55078)
twoertwein Sep 11, 2023
01ea1b1
DOC: fix an example which raises an Error in whatsnew/v0.10.0.rst (#5…
natmokval Sep 11, 2023
f74b988
ENH: numba engine in df.apply (#54666)
lithomas1 Sep 11, 2023
78f3efd
Merge remote-tracking branch 'upstream/main' into api/multi/tuple
mroeschke Sep 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/source/user_guide/groupby.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ the columns except the one we specify:
.. ipython:: python

df2 = df.set_index(["A", "B"])
grouped = df2.groupby(level=df2.index.names.difference(["B"]))
grouped = df2.groupby(level="A")
grouped.sum()

The above GroupBy will split the DataFrame on its index (rows). To split by columns, first do
Expand Down
4 changes: 2 additions & 2 deletions pandas/_libs/index.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ class MaskedUInt8Engine(MaskedIndexEngine): ...
class MaskedBoolEngine(MaskedUInt8Engine): ...

class BaseMultiIndexCodesEngine:
levels: list[np.ndarray]
levels: tuple[np.ndarray]
offsets: np.ndarray # ndarray[uint64_t, ndim=1]

def __init__(
self,
levels: list[np.ndarray], # all entries hashable
levels: tuple[np.ndarray], # all entries hashable
labels: list[np.ndarray], # all entries integer-dtyped
offsets: np.ndarray, # np.ndarray[np.uint64, ndim=1]
) -> None: ...
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -5775,7 +5775,7 @@ def _insert_quantile_level(idx: Index, qs: npt.NDArray[np.float64]) -> MultiInde
idx = cast(MultiIndex, idx)
levels = list(idx.levels) + [lev]
codes = [np.repeat(x, nqs) for x in idx.codes] + [np.tile(lev_codes, len(idx))]
mi = MultiIndex(levels=levels, codes=codes, names=idx.names + [None])
mi = MultiIndex(levels=levels, codes=codes, names=list(idx.names) + [None])
else:
nidx = len(idx)
idx_codes = coerce_indexer_dtype(np.arange(nidx), idx)
Expand Down
27 changes: 13 additions & 14 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@
disallow_ndim_indexing,
is_valid_positional_slice,
)
from pandas.core.indexes.frozen import FrozenList
from pandas.core.missing import clean_reindex_fill_method
from pandas.core.ops import get_op_result_name
from pandas.core.ops.invalid import make_invalid_op
Expand Down Expand Up @@ -1725,8 +1724,8 @@ def _get_default_index_names(

return names

def _get_names(self) -> FrozenList:
return FrozenList((self.name,))
def _get_names(self) -> tuple[Hashable, ...]:
return (self.name,)

def _set_names(self, values, *, level=None) -> None:
"""
Expand Down Expand Up @@ -1824,7 +1823,7 @@ def set_names(self, names, *, level=None, inplace: bool = False) -> Self | None:
('python', 2019),
( 'cobra', 2018),
( 'cobra', 2019)],
names=['species', 'year'])
names=('species', 'year'))

When renaming levels with a dict, levels can not be passed.

Expand All @@ -1833,7 +1832,7 @@ def set_names(self, names, *, level=None, inplace: bool = False) -> Self | None:
('python', 2019),
( 'cobra', 2018),
( 'cobra', 2019)],
names=['snake', 'year'])
names=('snake', 'year'))
"""
if level is not None and not isinstance(self, ABCMultiIndex):
raise ValueError("Level must be None for non-MultiIndex")
Expand Down Expand Up @@ -1912,13 +1911,13 @@ def rename(self, name, inplace: bool = False):
('python', 2019),
( 'cobra', 2018),
( 'cobra', 2019)],
names=['kind', 'year'])
names=('kind', 'year'))
>>> idx.rename(['species', 'year'])
MultiIndex([('python', 2018),
('python', 2019),
( 'cobra', 2018),
( 'cobra', 2019)],
names=['species', 'year'])
names=('species', 'year'))
>>> idx.rename('species')
Traceback (most recent call last):
TypeError: Must pass list-like as `names`.
Expand Down Expand Up @@ -2077,26 +2076,26 @@ def droplevel(self, level: IndexLabel = 0):
Examples
--------
>>> mi = pd.MultiIndex.from_arrays(
... [[1, 2], [3, 4], [5, 6]], names=['x', 'y', 'z'])
... [[1, 2], [3, 4], [5, 6]], names=('x', 'y', 'z'))
>>> mi
MultiIndex([(1, 3, 5),
(2, 4, 6)],
names=['x', 'y', 'z'])
names=('x', 'y', 'z'))

>>> mi.droplevel()
MultiIndex([(3, 5),
(4, 6)],
names=['y', 'z'])
names=('y', 'z'))

>>> mi.droplevel(2)
MultiIndex([(1, 3),
(2, 4)],
names=['x', 'y'])
names=('x', 'y'))

>>> mi.droplevel('z')
MultiIndex([(1, 3),
(2, 4)],
names=['x', 'y'])
names=('x', 'y'))

>>> mi.droplevel(['x', 'y'])
Index([5, 6], dtype='int64', name='z')
Expand Down Expand Up @@ -6487,7 +6486,7 @@ def isin(self, values, level=None) -> npt.NDArray[np.bool_]:
MultiIndex([(1, 'red'),
(2, 'blue'),
(3, 'green')],
names=['number', 'color'])
names=('number', 'color'))

Check whether the strings in the 'color' level of the MultiIndex
are in a list of colors.
Expand Down Expand Up @@ -7460,7 +7459,7 @@ def ensure_index_from_sequences(sequences, names=None) -> Index:
>>> ensure_index_from_sequences([["a", "a"], ["a", "b"]], names=["L1", "L2"])
MultiIndex([('a', 'a'),
('a', 'b')],
names=['L1', 'L2'])
names=('L1', 'L2'))

See Also
--------
Expand Down
120 changes: 0 additions & 120 deletions pandas/core/indexes/frozen.py

This file was deleted.

Loading