Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_from_dataframe():
df = pd.DataFrame({
'A': 1.,
'B': pd.Timestamp('20130102'),
'C': pd.Series(1, index=list(range(4)), dtype='float32'),
'D': np.array([False, True, False, False], dtype='bool'),
'S': pd.Categorical(["test", "train", "test", "train"]),
'T': 'foo'})
sheet = ipysheet.from_dataframe(df)
assert len(sheet.cells) == 6
assert sheet.column_headers == ['A', 'B', 'C', 'D', 'S', 'T']
assert sheet.cells[0].value == [1., 1., 1., 1.]
assert sheet.cells[0].type == 'numeric'
assert sheet.cells[1].value == ['2013/01/02', '2013/01/02', '2013/01/02', '2013/01/02']
assert sheet.cells[1].type == 'date'
assert sheet.cells[2].value == [1., 1., 1., 1.]
assert sheet.cells[2].type == 'numeric'
assert sheet.cells[3].value == [False, True, False, False]
assert sheet.cells[3].type == 'checkbox'
assert sheet.cells[4].value == ['test', 'train', 'test', 'train']
assert sheet.cells[4].type == 'text'
assert sheet.cells[5].value == ['foo', 'foo', 'foo', 'foo']
assert sheet.cells[5].type == 'text'