Skip to content

Commit

Permalink
TST:Test to_sparse with nan dataframe (pandas-dev#10079) (pandas-dev#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mroeschke authored and ShaharBental committed Dec 26, 2016
1 parent 808f386 commit 71a5c59
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pandas/sparse/tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,21 @@ def test_constructor_preserve_attr(self):
self.assertEqual(df['x'].dtype, np.int64)
self.assertEqual(df['x'].fill_value, 0)

def test_constructor_nan_dataframe(self):
# GH 10079
trains = np.arange(100)
tresholds = [10, 20, 30, 40, 50, 60]
tuples = [(i, j) for i in trains for j in tresholds]
index = pd.MultiIndex.from_tuples(tuples,
names=['trains', 'tresholds'])
matrix = np.empty((len(index), len(trains)))
matrix.fill(np.nan)
df = pd.DataFrame(matrix, index=index, columns=trains, dtype=float)
result = df.to_sparse()
expected = pd.SparseDataFrame(matrix, index=index, columns=trains,
dtype=float)
tm.assert_sp_frame_equal(result, expected)

def test_dtypes(self):
df = DataFrame(np.random.randn(10000, 4))
df.ix[:9998] = np.nan
Expand Down

0 comments on commit 71a5c59

Please sign in to comment.