From d30c27bcdd5e49e0e9439a75d675b85847754c1e Mon Sep 17 00:00:00 2001 From: Brock Date: Thu, 29 Oct 2020 15:31:50 -0700 Subject: [PATCH 1/2] TST: pct_change --- pandas/tests/frame/methods/test_pct_change.py | 21 +++++++++++++++++ pandas/tests/generic/test_generic.py | 23 ------------------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/pandas/tests/frame/methods/test_pct_change.py b/pandas/tests/frame/methods/test_pct_change.py index 8f3f37fb9fff7..56fb9ab0d8f00 100644 --- a/pandas/tests/frame/methods/test_pct_change.py +++ b/pandas/tests/frame/methods/test_pct_change.py @@ -6,6 +6,27 @@ class TestDataFramePctChange: + @pytest.mark.parametrize( + "periods,fill_method,limit,exp", + [ + (1, "ffill", None, [np.nan, np.nan, np.nan, 1, 1, 1.5, 0, 0]), + (1, "ffill", 1, [np.nan, np.nan, np.nan, 1, 1, 1.5, 0, np.nan]), + (1, "bfill", None, [np.nan, 0, 0, 1, 1, 1.5, np.nan, np.nan]), + (1, "bfill", 1, [np.nan, np.nan, 0, 1, 1, 1.5, np.nan, np.nan]), + (-1, "ffill", None, [np.nan, np.nan, -0.5, -0.5, -0.6, 0, 0, np.nan]), + (-1, "ffill", 1, [np.nan, np.nan, -0.5, -0.5, -0.6, 0, np.nan, np.nan]), + (-1, "bfill", None, [0, 0, -0.5, -0.5, -0.6, np.nan, np.nan, np.nan]), + (-1, "bfill", 1, [np.nan, 0, -0.5, -0.5, -0.6, np.nan, np.nan, np.nan]), + ], + ) + @pytest.mark.parametrize("klass", [DataFrame, Series]) + def test_pct_change_with_nas(self, periods, fill_method, limit, exp, klass): + vals = [np.nan, np.nan, 1, 2, 4, 10, np.nan, np.nan] + obj = klass(vals) + + res = obj.pct_change(periods=periods, fill_method=fill_method, limit=limit) + tm.assert_equal(res, klass(exp)) + def test_pct_change_numeric(self): # GH#11150 pnl = DataFrame( diff --git a/pandas/tests/generic/test_generic.py b/pandas/tests/generic/test_generic.py index cccae1babe82f..45601abc95fe6 100644 --- a/pandas/tests/generic/test_generic.py +++ b/pandas/tests/generic/test_generic.py @@ -356,29 +356,6 @@ def test_copy_and_deepcopy(self, shape, func): assert obj_copy is not obj self._compare(obj_copy, obj) - @pytest.mark.parametrize( - "periods,fill_method,limit,exp", - [ - (1, "ffill", None, [np.nan, np.nan, np.nan, 1, 1, 1.5, 0, 0]), - (1, "ffill", 1, [np.nan, np.nan, np.nan, 1, 1, 1.5, 0, np.nan]), - (1, "bfill", None, [np.nan, 0, 0, 1, 1, 1.5, np.nan, np.nan]), - (1, "bfill", 1, [np.nan, np.nan, 0, 1, 1, 1.5, np.nan, np.nan]), - (-1, "ffill", None, [np.nan, np.nan, -0.5, -0.5, -0.6, 0, 0, np.nan]), - (-1, "ffill", 1, [np.nan, np.nan, -0.5, -0.5, -0.6, 0, np.nan, np.nan]), - (-1, "bfill", None, [0, 0, -0.5, -0.5, -0.6, np.nan, np.nan, np.nan]), - (-1, "bfill", 1, [np.nan, 0, -0.5, -0.5, -0.6, np.nan, np.nan, np.nan]), - ], - ) - def test_pct_change(self, periods, fill_method, limit, exp): - vals = [np.nan, np.nan, 1, 2, 4, 10, np.nan, np.nan] - obj = self._typ(vals) - func = getattr(obj, "pct_change") - res = func(periods=periods, fill_method=fill_method, limit=limit) - if type(obj) is DataFrame: - tm.assert_frame_equal(res, DataFrame(exp)) - else: - tm.assert_series_equal(res, Series(exp)) - class TestNDFrame: # tests that don't fit elsewhere From 17e248e5b4d46e08beee6ef575f92a93d5e1ab5e Mon Sep 17 00:00:00 2001 From: Brock Date: Thu, 29 Oct 2020 18:49:30 -0700 Subject: [PATCH 2/2] dummy commit to force azure