def test_of(self): expected = [[1, 2, 3], [4, 5, 6]] df = UntypedDf.convert(pd.DataFrame(sample_data())) assert df.to_numpy().tolist() == expected df = UntypedDf.of(pd.DataFrame(sample_data())) assert df.to_numpy().tolist() == expected df = UntypedDf.of(sample_data()) assert df.to_numpy().tolist() == expected
def test_iter_rc(self): df = UntypedDf.convert(pd.DataFrame(sample_data())) expected = [((0, 0), 1), ((0, 1), 2), ((0, 2), 3), ((1, 0), 4), ((1, 1), 5), ((1, 2), 6)] assert list(df.iter_row_col()) == expected
def test_set_attrs(self): df = UntypedDf.convert(pd.DataFrame(sample_data())) df2 = df.set_attrs(animal="fishies") assert df2.attrs == dict(animal="fishies") assert df.attrs == {}
def test_set_index(self): df = UntypedDf.convert(pd.DataFrame(sample_data()).set_index("abc")) assert df.set_index([]).index_names() == [] assert df.set_index([], append=True).index_names() == ["abc"] with pytest.raises(UnsupportedOperationError): df.set_index([], inplace=True)