Skip to content

Commit ac7a6df

Browse files
committed
various changes
1 parent 411c740 commit ac7a6df

File tree

10 files changed

+193
-111
lines changed

10 files changed

+193
-111
lines changed

doc/source/whatsnew/v0.24.0.rst

+8
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,14 @@ Other API Changes
11001100
Deprecations
11011101
~~~~~~~~~~~~
11021102

1103+
- :attr:`MultiIndex.labels` has been deprecated and replaced by :attr:`MultiIndex.codes`.
1104+
The functionality is unchanged. This new name better reflects the natures of
1105+
these codes and makes the API more similar to the API for
1106+
:class:`CategoricalIndex`(:issue:`13443`).
1107+
As a concequence, other uses of the name ``labels`` have also been deprecated in ``MultiIndex`` and replaced with ``codes``:
1108+
- You should initialize a MultiIndex instance using a parameter named ``codes`` rather than ``labels``.
1109+
- :meth:`MultiIndex.set_labels` has been deprecated in favor of :meth:`MultiIndex.set_codes`
1110+
- for method :meth:`MultiIndex.copy`, the ``labels`` parameter has been deprecated and replaced by a ``codes`` parameter.
11031111
- :meth:`DataFrame.to_stata`, :meth:`read_stata`, :class:`StataReader` and :class:`StataWriter` have deprecated the ``encoding`` argument. The encoding of a Stata dta file is determined by the file type and cannot be changed (:issue:`21244`)
11041112
- :meth:`MultiIndex.to_hierarchical` is deprecated and will be removed in a future version (:issue:`21613`)
11051113
- :meth:`Series.ptp` is deprecated. Use ``numpy.ptp`` instead (:issue:`21614`)

pandas/core/indexes/base.py

+43
Original file line numberDiff line numberDiff line change
@@ -4103,12 +4103,24 @@ def asof_locs(self, where, mask):
41034103

41044104
return result
41054105

4106+
<<<<<<< HEAD
41064107
def sort_values(self, return_indexer=False, ascending=True):
41074108
"""
41084109
Return a sorted copy of the index.
41094110
41104111
Return a sorted copy of the index, and optionally return the indices
41114112
that sorted the index itself.
4113+
=======
4114+
levels, codes, names = (
4115+
_restore_dropped_levels_multijoin(self, other,
4116+
dropped_names,
4117+
join_idx,
4118+
lidx, ridx))
4119+
4120+
# Re-create the multi-index
4121+
multi_join_idx = MultiIndex(levels=levels, codes=codes,
4122+
names=names, verify_integrity=False)
4123+
>>>>>>> various changes
41124124
41134125
Parameters
41144126
----------
@@ -4466,15 +4478,24 @@ def isin(self, values, level=None):
44664478
passed set of values. The length of the returned boolean array matches
44674479
the length of the index.
44684480
4481+
<<<<<<< HEAD
44694482
Parameters
44704483
----------
44714484
values : set or list-like
44724485
Sought values.
44734486
44744487
.. versionadded:: 0.18.1
4488+
=======
4489+
new_level_codes = algos.take_nd(rev_indexer, left.codes[level],
4490+
allow_fill=False)
4491+
4492+
new_codes = list(left.codes)
4493+
new_codes[level] = new_level_codes
4494+
>>>>>>> various changes
44754495
44764496
Support for values as a set.
44774497
4498+
<<<<<<< HEAD
44784499
level : str or int, optional
44794500
Name or position of the index level to use (if the index is a
44804501
`MultiIndex`).
@@ -4483,18 +4504,40 @@ def isin(self, values, level=None):
44834504
-------
44844505
is_contained : ndarray
44854506
NumPy array of boolean values.
4507+
=======
4508+
if keep_order: # just drop missing values. o.w. keep order
4509+
left_indexer = np.arange(len(left), dtype=np.intp)
4510+
mask = new_level_codes != -1
4511+
if not mask.all():
4512+
new_codes = [codes_[mask] for codes_ in new_codes]
4513+
left_indexer = left_indexer[mask]
4514+
4515+
else: # tie out the order with other
4516+
if level == 0: # outer most level, take the fast route
4517+
ngroups = 1 + new_level_codes.max()
4518+
left_indexer, counts = libalgos.groupsort_indexer(
4519+
new_level_codes, ngroups)
4520+
>>>>>>> various changes
44864521
44874522
See Also
44884523
--------
44894524
Series.isin : Same for Series.
44904525
DataFrame.isin : Same method for DataFrames.
44914526
4527+
<<<<<<< HEAD
44924528
Notes
44934529
-----
44944530
In the case of `MultiIndex` you must either specify `values` as a
44954531
list-like object containing tuples that are the same length as the
44964532
number of levels, or specify `level`. Otherwise it will raise a
44974533
``ValueError``.
4534+
=======
4535+
else: # sort the leaves
4536+
mask = new_level_codes != -1
4537+
mask_all = mask.all()
4538+
if not mask_all:
4539+
new_codes = [lab[mask] for lab in new_codes]
4540+
>>>>>>> various changes
44984541
44994542
If `level` is specified:
45004543

0 commit comments

Comments
 (0)