Skip to content

Commit 15d8433

Browse files
committed
Address jreback comments
1 parent 10667a3 commit 15d8433

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

doc/source/whatsnew/v0.20.0.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,12 @@ Other enhancements
185185
- ``Series/DataFrame.asfreq()`` have gained a ``fill_value`` parameter, to fill missing values (:issue:`3715`).
186186
- ``Series/DataFrame.resample.asfreq`` have gained a ``fill_value`` parameter, to fill missing values during resampling (:issue:`3715`).
187187
- ``pandas.tools.hashing`` has gained a ``hash_tuples`` routine, and ``hash_pandas_object`` has gained the ability to hash a ``MultiIndex`` (:issue:`15224`)
188-
- ``Series/DataFrame.squeeze()`` have gained the ``axis`` parameter. (:issue:`15339`)<<<<<<< f4edb053e17e51e8c2bed7c16755c4f7f3222117
188+
- ``Series/DataFrame.squeeze()`` have gained the ``axis`` parameter. (:issue:`15339`)
189189
- ``DataFrame.to_excel()`` has a new ``freeze_panes`` parameter to turn on Freeze Panes when exporting to Excel (:issue:`15160`)
190190
- HTML table output skips ``colspan`` or ``rowspan`` attribute if equal to 1. (:issue:`15403`)
191191
- ``pd.TimedeltaIndex`` now has a custom datetick formatter specifically designed for nanosecond level precision (:issue:`8711`)
192192
- ``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.
193-
- Using numerical names in ``MultiIndex`` causes less errors. (:issue:`12223`) (:issue:`15262`)
193+
- Fixed issue when using ``pd.concat`` that affected ``MultiIndex`` output formatting when names of index were int (:issue:`12223`, :issue:`15262`)
194194

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

pandas/indexes/base.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -2353,8 +2353,21 @@ def get_level_values(self, level):
23532353
return self
23542354

23552355
def _get_level_values(self, num):
2356-
# Used to mirror implementation for MultiIndex
2357-
# GH #10461
2356+
"""
2357+
Return vector of label values for requested level, equal to the length
2358+
of the index
2359+
2360+
**this is an internal method**
2361+
2362+
Parameters
2363+
----------
2364+
level : int
2365+
2366+
Returns
2367+
-------
2368+
values : ndarray
2369+
"""
2370+
# Needed to address discussion in GH #10461
23582371
return self.get_level_values(num)
23592372

23602373
_index_shared_docs['get_indexer'] = """

pandas/indexes/multi.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ def is_monotonic_increasing(self):
684684
"""
685685

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

847847
raise InvalidIndexError(key)
848848

849-
def _get_level_values(self, level, copy=True):
849+
def _get_level_values(self, level):
850850
"""
851851
Return vector of label values for requested level,
852852
equal to the length of the index
@@ -856,7 +856,6 @@ def _get_level_values(self, level, copy=True):
856856
Parameters
857857
----------
858858
level : int level
859-
copy : bool whether copy of results should be done
860859
861860
Returns
862861
-------
@@ -867,10 +866,7 @@ def _get_level_values(self, level, copy=True):
867866
labels = self.labels[level]
868867
filled = algos.take_1d(unique._values, labels,
869868
fill_value=unique._na_value)
870-
if copy:
871-
values = unique._shallow_copy(filled)
872-
else:
873-
values = filled
869+
values = unique._shallow_copy(filled)
874870
return values
875871

876872
def get_level_values(self, level):
@@ -887,8 +883,8 @@ def get_level_values(self, level):
887883
values : Index
888884
"""
889885
level = self._get_level_number(level)
890-
values = self._get_level_values(level, copy=False)
891-
return self.levels[level]._shallow_copy(values)
886+
values = self._get_level_values(level)
887+
return values
892888

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

0 commit comments

Comments
 (0)