Skip to content

Commit 56a7bb5

Browse files
committed
minor changes
1 parent 3e467a7 commit 56a7bb5

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

doc/source/advanced.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ values across a level. For instance:
474474
.. ipython:: python
475475
476476
midx = pd.MultiIndex(levels=[['zero', 'one'], ['x', 'y']],
477-
codes=[[1, 1, 0, 0],[1, 0, 1, 0]])
477+
codes=[[1, 1, 0, 0], [1, 0, 1, 0]])
478478
df = pd.DataFrame(np.random.randn(4, 2), index=midx)
479479
df
480480
df2 = df.mean(level=0)

doc/source/whatsnew/v0.24.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ Deprecations
11011101
~~~~~~~~~~~~
11021102

11031103
- :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
1104+
The functionality is unchanged. The new name better reflects the natures of
11051105
these codes and makes the ``MultiIndex`` API more similar to the API for
11061106
:class:`CategoricalIndex`(:issue:`13443`).
11071107
As a consequence, other uses of the name ``labels`` in ``MultiIndex`` have also been deprecated and replaced with ``codes``:

pandas/core/groupby/generic.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1191,10 +1191,10 @@ def value_counts(self, normalize=False, sort=True, ascending=False,
11911191
out, left[-1] = out[sorter], left[-1][sorter]
11921192

11931193
# build the multi-index w/ full levels
1194-
labels = list(map(lambda lab: np.repeat(lab[diff], nbin), labels[:-1]))
1195-
labels.append(left[-1])
1194+
codes = list(map(lambda lab: np.repeat(lab[diff], nbin), labels[:-1]))
1195+
codes.append(left[-1])
11961196

1197-
mi = MultiIndex(levels=levels, codes=labels, names=names,
1197+
mi = MultiIndex(levels=levels, codes=codes, names=names,
11981198
verify_integrity=False)
11991199

12001200
if is_integer_dtype(out):

pandas/core/indexes/multi.py

+4
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,10 @@ def set_codes(self, codes, level=None, inplace=False,
633633
Set new codes on MultiIndex. Defaults to returning
634634
new index.
635635
636+
.. versionadded:: 0.24.0
637+
638+
New name for deprecated method `set_labels`.
639+
636640
Parameters
637641
----------
638642
codes : sequence or list of sequence

0 commit comments

Comments
 (0)