Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
topper-123 committed Dec 4, 2018
1 parent 3e467a7 commit 56a7bb5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion doc/source/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ values across a level. For instance:
.. ipython:: python
midx = pd.MultiIndex(levels=[['zero', 'one'], ['x', 'y']],
codes=[[1, 1, 0, 0],[1, 0, 1, 0]])
codes=[[1, 1, 0, 0], [1, 0, 1, 0]])
df = pd.DataFrame(np.random.randn(4, 2), index=midx)
df
df2 = df.mean(level=0)
Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.24.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ Deprecations
~~~~~~~~~~~~

- :attr:`MultiIndex.labels` has been deprecated and replaced by :attr:`MultiIndex.codes`.
The functionality is unchanged. This new name better reflects the natures of
The functionality is unchanged. The new name better reflects the natures of
these codes and makes the ``MultiIndex`` API more similar to the API for
:class:`CategoricalIndex`(:issue:`13443`).
As a consequence, other uses of the name ``labels`` in ``MultiIndex`` have also been deprecated and replaced with ``codes``:
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/groupby/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1191,10 +1191,10 @@ def value_counts(self, normalize=False, sort=True, ascending=False,
out, left[-1] = out[sorter], left[-1][sorter]

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

mi = MultiIndex(levels=levels, codes=labels, names=names,
mi = MultiIndex(levels=levels, codes=codes, names=names,
verify_integrity=False)

if is_integer_dtype(out):
Expand Down
4 changes: 4 additions & 0 deletions pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,10 @@ def set_codes(self, codes, level=None, inplace=False,
Set new codes on MultiIndex. Defaults to returning
new index.
.. versionadded:: 0.24.0
New name for deprecated method `set_labels`.
Parameters
----------
codes : sequence or list of sequence
Expand Down

0 comments on commit 56a7bb5

Please sign in to comment.