Skip to content

Commit

Permalink
TST: NaN in MultiIndex should not become a string (pandas-dev#7031) (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
dsm054 authored and Kiv committed Jun 11, 2017
1 parent 4b0ef03 commit 1b159af
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions pandas/tests/indexes/test_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2866,3 +2866,24 @@ def test_tuples_with_name_string(self):
pd.Index(li, name='abc')
with pytest.raises(ValueError):
pd.Index(li, name='a')

def test_nan_stays_float(self):

# GH 7031
idx0 = pd.MultiIndex(levels=[["A", "B"], []],
labels=[[1, 0], [-1, -1]],
names=[0, 1])
idx1 = pd.MultiIndex(levels=[["C"], ["D"]],
labels=[[0], [0]],
names=[0, 1])
idxm = idx0.join(idx1, how='outer')
assert pd.isnull(idx0.get_level_values(1)).all()
# the following failed in 0.14.1
assert pd.isnull(idxm.get_level_values(1)[:-1]).all()

df0 = pd.DataFrame([[1, 2]], index=idx0)
df1 = pd.DataFrame([[3, 4]], index=idx1)
dfm = df0 - df1
assert pd.isnull(df0.index.get_level_values(1)).all()
# the following failed in 0.14.1
assert pd.isnull(dfm.index.get_level_values(1)[:-1]).all()

0 comments on commit 1b159af

Please sign in to comment.