|
14 | 14 | ) |
15 | 15 |
|
16 | 16 |
|
17 | | -def test_interpolate_missing_values() -> None: |
18 | | - expected = pd.DataFrame( |
19 | | - { |
20 | | - "depth": [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0], |
21 | | - "A": [0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0], |
22 | | - "B": [0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0], |
23 | | - "C": [0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0], |
24 | | - "D": [0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0], |
25 | | - } |
26 | | - ) |
27 | | - result = interpolate_missing_values(df, key_col="depth") |
28 | | - pd.testing.assert_frame_equal(result, expected) |
| 17 | +class Test_Interpolation: |
| 18 | + def test_interpolate_missing_values__linear_method(self) -> None: |
| 19 | + expected = pd.DataFrame( |
| 20 | + { |
| 21 | + "depth": [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0], |
| 22 | + "A": [0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0], |
| 23 | + "B": [0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0], |
| 24 | + "C": [0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0], |
| 25 | + "D": [0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0], |
| 26 | + } |
| 27 | + ) |
| 28 | + result = interpolate_missing_values(df, key_col="depth", mode="linear") |
| 29 | + pd.testing.assert_frame_equal(result, expected) |
| 30 | + |
| 31 | + def test_interpolate_missing_values__padding_method(self) -> None: |
| 32 | + expected = pd.DataFrame( |
| 33 | + { |
| 34 | + "depth": [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0], |
| 35 | + "A": [np.nan, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 90.0, 90.0], |
| 36 | + "B": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 90.0, 90.0], |
| 37 | + "C": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 100.0], |
| 38 | + "D": [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, 80.0, 80.0, 100.0], |
| 39 | + } |
| 40 | + ) |
| 41 | + result = interpolate_missing_values(df, mode="padding") |
| 42 | + pd.testing.assert_frame_equal(result, expected) |
0 commit comments