コード例 #1
0
 def test_drop_nan_row_all(self, stream_wf):
     """tests for dropping a row with all NaN"""
     wf = make_wf_with_nan(stream_wf, y_inds=0)
     wf2 = wf.dropna(0, how="all")
     assert wf2 == wf.dropna(0, how="any")
     # starttimes should not have changed
     assert (wf["starttime"][1:] == wf2["starttime"]).all()
コード例 #2
0
 def test_drop_start_and_end(self, stream_wf):
     """Drop a few samples from start and end, ensure times update."""
     wf = make_wf_with_nan(stream_wf, x_inds=(0, 1, -2, -1))
     delta = wf["delta"][0]
     start, end = wf["starttime"], wf["endtime"]
     # drop NaN, ensure start/end times are as expected.
     out = wf.dropna(axis=1, how="any")
     assert (out["starttime"] == (start + 2 * delta)).all()
     assert (out["endtime"] == (end - 2 * delta)).all()
コード例 #3
0
 def test_drop_nan_column_any(self, stream_wf):
     """Tests for dropping a column with one NaN."""
     wf = make_wf_with_nan(stream_wf, 0, 0)
     # since only one value is NaN using how==all does nothing
     assert wf == wf.dropna(1, how="all")
     # but how==any should
     wf2 = wf.dropna(1, how="any")
     assert (wf["starttime"] < wf2["starttime"]).all()
     # the first index should always be 0
     assert wf2.data.columns[0] == 0
コード例 #4
0
 def test_drop_nan_column_all(self, stream_wf):
     """Tests for dropping a column with all NaN."""
     wf = make_wf_with_nan(stream_wf, x_inds=0)
     # first test drops based on rows, this should drop all rows
     wf2 = wf.dropna(1, how="any")
     assert wf2 is not wf
     # there should no longer be any NaN
     assert not wf2.data.isnull().any().any()
     # the start of the columns should be 0
     assert wf2.data.columns[0] == 0
     # the starttime should have been updated
     assert (wf2["starttime"] > wf["starttime"]).all()
     # dropping using the all keyword should also work
     assert wf.dropna(1, how="all") == wf2
コード例 #5
0
 def wf_offset_nan(self, wf_with_offset):
     """Add some NaN to offsets, just for fun."""
     return make_wf_with_nan(wf_with_offset, x_inds=self.nan_x_inds)
コード例 #6
0
 def test_basic(self, stream_wf):
     """Simple test for filling on NaN value."""
     wf = make_wf_with_nan(stream_wf, x_inds=0, y_inds=0)
     out = wf.fillna(2019)
     assert out.data.loc[0, 0] == 2019
コード例 #7
0
 def test_drop_all(self, stream_wf):
     """tests for when all rows are dropped."""
     wf = make_wf_with_nan(stream_wf, x_inds=0)
     wf2 = wf.dropna(0, how="any")
     assert len(wf2) == 0
コード例 #8
0
 def test_drop_nan_row_any(self, stream_wf):
     """test for dropping a row with one NaN."""
     wf = make_wf_with_nan(stream_wf, y_inds=0, x_inds=0)
     wf2 = wf.dropna(0, how="any")
     wf3 = wf.dropna(0, how="all")
     assert len(wf3) > len(wf2)