Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Address jreback comments
  • Loading branch information
Dr-Irv committed Feb 23, 2017
commit 15d843307a23c169f4f34eb3ca1fa52c036354bc
4 changes: 2 additions & 2 deletions doc/source/whatsnew/v0.20.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,12 @@ Other enhancements
- ``Series/DataFrame.asfreq()`` have gained a ``fill_value`` parameter, to fill missing values (:issue:`3715`).
- ``Series/DataFrame.resample.asfreq`` have gained a ``fill_value`` parameter, to fill missing values during resampling (:issue:`3715`).
- ``pandas.tools.hashing`` has gained a ``hash_tuples`` routine, and ``hash_pandas_object`` has gained the ability to hash a ``MultiIndex`` (:issue:`15224`)
- ``Series/DataFrame.squeeze()`` have gained the ``axis`` parameter. (:issue:`15339`)<<<<<<< f4edb053e17e51e8c2bed7c16755c4f7f3222117
- ``Series/DataFrame.squeeze()`` have gained the ``axis`` parameter. (:issue:`15339`)
- ``DataFrame.to_excel()`` has a new ``freeze_panes`` parameter to turn on Freeze Panes when exporting to Excel (:issue:`15160`)
- HTML table output skips ``colspan`` or ``rowspan`` attribute if equal to 1. (:issue:`15403`)
- ``pd.TimedeltaIndex`` now has a custom datetick formatter specifically designed for nanosecond level precision (:issue:`8711`)
- ``pd.types.concat.union_categoricals`` gained the ``ignore_ordered`` argument to allow ignoring the ordered attribute of unioned categoricals (:issue:`13410`). See the :ref:`categorical union docs <categorical.union>` for more information.
- Using numerical names in ``MultiIndex`` causes less errors. (:issue:`12223`) (:issue:`15262`)
- Fixed issue when using ``pd.concat`` that affected ``MultiIndex`` output formatting when names of index were int (:issue:`12223`, :issue:`15262`)

.. _ISO 8601 duration: https://en.wikipedia.org/wiki/ISO_8601#Durations

Expand Down
17 changes: 15 additions & 2 deletions pandas/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2353,8 +2353,21 @@ def get_level_values(self, level):
return self

def _get_level_values(self, num):
# Used to mirror implementation for MultiIndex
# GH #10461
"""
Return vector of label values for requested level, equal to the length
of the index

**this is an internal method**

Parameters
----------
level : int

Returns
-------
values : ndarray
"""
# Needed to address discussion in GH #10461
return self.get_level_values(num)

_index_shared_docs['get_indexer'] = """
Expand Down
14 changes: 5 additions & 9 deletions pandas/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ def is_monotonic_increasing(self):
"""

# reversed() because lexsort() wants the most significant key last.
values = [self._get_level_values(i)
values = [self._get_level_values(i).values
for i in reversed(range(len(self.levels)))]
try:
sort_order = np.lexsort(values)
Expand Down Expand Up @@ -846,7 +846,7 @@ def _try_mi(k):

raise InvalidIndexError(key)

def _get_level_values(self, level, copy=True):
def _get_level_values(self, level):
"""
Return vector of label values for requested level,
equal to the length of the index
Expand All @@ -856,7 +856,6 @@ def _get_level_values(self, level, copy=True):
Parameters
----------
level : int level
copy : bool whether copy of results should be done

Returns
-------
Expand All @@ -867,10 +866,7 @@ def _get_level_values(self, level, copy=True):
labels = self.labels[level]
filled = algos.take_1d(unique._values, labels,
fill_value=unique._na_value)
if copy:
values = unique._shallow_copy(filled)
else:
values = filled
values = unique._shallow_copy(filled)
return values

def get_level_values(self, level):
Expand All @@ -887,8 +883,8 @@ def get_level_values(self, level):
values : Index
"""
level = self._get_level_number(level)
values = self._get_level_values(level, copy=False)
return self.levels[level]._shallow_copy(values)
values = self._get_level_values(level)
return values

def format(self, space=2, sparsify=None, adjoin=True, names=False,
na_rep=None, formatter=None):
Expand Down