Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST:Test to_sparse with nan dataframe (#10079) #14913

Merged
merged 1 commit into from
Dec 19, 2016
Merged
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
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