Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/source/whatsnew/v0.18.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,5 @@ Bug Fixes


- Bug in ``fill_value`` is ignored if the argument to a binary operator is a constant (:issue `12723`)

- Bug in index coercion when falling back from ```RangeIndex``` construction (:issue:`12893`)
2 changes: 1 addition & 1 deletion pandas/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ def get_level_values(self, level):
filled = algos.take_1d(unique.values, labels,
fill_value=unique._na_value)
_simple_new = unique._simple_new
values = _simple_new(filled, self.names[num],
values = _simple_new(filled, name=self.names[num],
freq=getattr(unique, 'freq', None),
tz=getattr(unique, 'tz', None))
return values
Expand Down
9 changes: 9 additions & 0 deletions pandas/tests/indexes/test_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2130,3 +2130,12 @@ def test_partial_string_timestamp_multiindex(self):
# Slicing date on first level should break (of course)
with assertRaises(KeyError):
df_swap.loc['2016-01-01']

def test_rangeindex_fallback_coercion_bug(self):
# GH 12893
foo = pd.DataFrame(np.arange(100).reshape((10, 10)))
bar = pd.DataFrame(np.arange(100).reshape((10, 10)))
df = pd.concat({'foo': foo.stack(), 'bar': bar.stack()}, axis=1)
df.index.names = ['fizz', 'buzz']
expected = [i for i in range(10) for j in range(10)]
self.assertTrue((df.index.get_level_values('fizz') == expected).all())