Exemplo n.º 1
0
 def test_print_memory_use(self, mock_print):
     data = test.data_frame("vehicles.csv")
     data.print_memory_use()
     mock_print.assert_called()
Exemplo n.º 2
0
 def test_ncol(self):
     data = test.data_frame("vehicles.csv")
     assert data.ncol == 12
Exemplo n.º 3
0
 def test_nrow(self):
     data = test.data_frame("vehicles.csv")
     assert data.nrow == 33442
Exemplo n.º 4
0
 def test_modify(self):
     orig = test.data_frame("vehicles.csv")
     data = orig.modify(test=1)
     assert data.nrow == orig.nrow
     assert data.ncol == orig.ncol + 1
     assert np.all(data.test == 1)
Exemplo n.º 5
0
 def test_modify_function(self):
     orig = test.data_frame("vehicles.csv")
     data = orig.modify(test=lambda x: x.make)
     assert data.nrow == orig.nrow
     assert data.ncol == orig.ncol + 1
     assert np.all(data.test == data.make)
Exemplo n.º 6
0
 def test_read_npz(self):
     orig = test.data_frame("vehicles.csv")
     handle, path = tempfile.mkstemp(".npz")
     orig.write_npz(path)
     data = DataFrame.read_npz(path)
     assert data == orig
Exemplo n.º 7
0
 def test___setitem__(self):
     data = test.data_frame("vehicles.csv")
     assert "test" not in data
     data["test"] = 1
     assert "test" in data
Exemplo n.º 8
0
 def test_filter_out_given_colname_value_pairs(self):
     data = test.data_frame("vehicles.csv")
     data = data.filter_out(make="Saab")
     assert data.nrow == 33018
     assert np.all(data.make != "Saab")
     assert np.sum(data.hwy) == 776930
Exemplo n.º 9
0
 def test_from_json(self):
     orig = test.data_frame("downloads.json")
     text = orig.to_json()
     data = DataFrame.from_json(text)
     assert data == orig
Exemplo n.º 10
0
 def test_deepcopy(self):
     orig = test.data_frame("vehicles.csv")
     data = orig.copy()
     assert data == orig
     assert data is not orig
Exemplo n.º 11
0
 def test_filter_given_colname_value_pairs(self):
     data = test.data_frame("vehicles.csv")
     data = data.filter(make="Saab")
     assert data.nrow == 424
     assert np.all(data.make == "Saab")
     assert np.sum(data.hwy) == 10672
Exemplo n.º 12
0
 def test_columns(self):
     data = test.data_frame("downloads.csv")
     assert data.columns == [data.category, data.date, data.downloads]
Exemplo n.º 13
0
 def test_colnames_set(self):
     data = test.data_frame("downloads.csv")
     data.colnames = ["a", "b", "c"]
     assert data.colnames == ["a", "b", "c"]
Exemplo n.º 14
0
 def test_colnames(self):
     data = test.data_frame("downloads.csv")
     assert data.colnames == ["category", "date", "downloads"]
Exemplo n.º 15
0
 def test_print_na_counts(self, mock_print):
     data = test.data_frame("vehicles.csv")
     data.print_na_counts()
     mock_print.assert_called()
Exemplo n.º 16
0
 def test_head(self):
     data = test.data_frame("vehicles.csv")
     assert data.head(10) == data.slice(list(range(10)))
Exemplo n.º 17
0
 def test_print_na_counts_none(self, mock_print):
     data = test.data_frame("vehicles.csv")
     data = data.select("id", "make", "model")
     data.print_na_counts()
     mock_print.assert_not_called()
Exemplo n.º 18
0
 def test_map(self):
     data = test.data_frame("vehicles.csv")
     x = data.map(lambda x, i: x.hwy[i]**2)
     y = [x**2 for x in data.hwy]
     assert x == y
Exemplo n.º 19
0
 def test_read_npz_path(self):
     orig = test.data_frame("vehicles.csv")
     handle, path = tempfile.mkstemp(".npz")
     orig.write_npz(path)
     DataFrame.read_npz(Path(path))
Exemplo n.º 20
0
 def test___setattr__(self):
     data = test.data_frame("vehicles.csv")
     assert "test" not in data
     data.test = 1
     assert "test" in data