示例#1
0
 def test_st(self):
     df = UntypedDf().convert(pd.DataFrame(sample_data()))
     assert len(df[df["xyz"] == 6]) == 1
     assert len(df.st(df["xyz"] == 6)) == 1
     assert len(df.st(xyz=6)) == 1
     assert len(df.st(df["xyz"] == 6, df["xyz"] == 6)) == 1
     assert len(df.st(df["xyz"] == 6, df["xyz"] == 3)) == 0
     assert len(df.st(df["xyz"] == 6, xyz=6)) == 1
     assert len(df.st(df["xyz"] == 6, xyz=2)) == 0
     assert len(df.st(xyz=1, abc=1)) == 0
     assert len(df.st(df["xyz"] == 6, df["xyz"] == 1, xyz=6)) == 0
示例#2
0
 def test_pretty(self):
     assert (UntypedDf()._repr_html_().startswith(
         "<strong>UntypedDf: 0 rows × 0 columns</strong>"))
示例#3
0
 def test_write_passing_index(self):
     with tmpfile(".csv") as path:
         df = Trivial(sample_data())
         df.to_csv(path, index=["abc"])  # fine
         df = UntypedDf(sample_data())
         df.to_csv(path, index=["abc"])  # calls super immediately
示例#4
0
 def test_records(self):
     df = UntypedDf(sample_data())
     records = df.to_records()
     df2 = UntypedDf.from_records(records)
     assert isinstance(df2, UntypedDf)
示例#5
0
 def test_pretty(self):
     assert (UntypedDf()._repr_html_().startswith(
         "<strong>UntypedDf: 0 rows × 0 columns</strong>"))
     df = UntypedDf(sample_data()).set_index(["abc", "123"])
     assert (UntypedDf(df)._repr_html_().startswith(
         "<strong>UntypedDf: 2 rows × 1 columns, 2 index columns</strong>"))