From 03f01c72eb52b823b98c3b4cdb2af4ddcc055838 Mon Sep 17 00:00:00 2001 From: springcoil Date: Thu, 20 Aug 2015 20:05:21 +0200 Subject: [PATCH 1/5] BUG: 10633 and 10800 fix --- doc/source/whatsnew/v0.17.0.txt | 7 +++++ pandas/core/common.py | 17 +++++++++++ pandas/tests/test_generic.py | 51 +++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) diff --git a/doc/source/whatsnew/v0.17.0.txt b/doc/source/whatsnew/v0.17.0.txt index 13764543ec665..8dc38d85e9ff1 100644 --- a/doc/source/whatsnew/v0.17.0.txt +++ b/doc/source/whatsnew/v0.17.0.txt @@ -612,11 +612,18 @@ Performance Improvements Bug Fixes ~~~~~~~~~ +<<<<<<< HEAD - Bug in ``DataFrame.to_html(index=False)`` renders unnecessary ``name`` row (:issue:`10344`) +======= + + +- Bug in ``DataFrame.to_html(index=False)`` renders unnecessary ``name`` row (:issue:`10344`) +>>>>>>> updating examples and the bug fix - Bug in ``DataFrame.apply`` when function returns categorical series. (:issue:`9573`) - Bug in ``to_datetime`` with invalid dates and formats supplied (:issue:`10154`) - Bug in ``Index.drop_duplicates`` dropping name(s) (:issue:`10115`) - Bug in ``pd.Series`` when setting a value on an empty ``Series`` whose index has a frequency. (:issue:`10193`) +- Bug in ``pd.Series.interpolate`` when setting no order value on ``Series.interpolate`` this needs to be at least 1. (:issue:`10633`) and (:issue:`10800`) - Bug in ``DataFrame.plot`` raises ``ValueError`` when color name is specified by multiple characters (:issue:`10387`) - Bug in ``Index`` construction with a mixed list of tuples (:issue:`10697`) - Bug in ``DataFrame.reset_index`` when index contains `NaT`. (:issue:`10388`) diff --git a/pandas/core/common.py b/pandas/core/common.py index aaa341240f538..49bf9cefd9785 100644 --- a/pandas/core/common.py +++ b/pandas/core/common.py @@ -1718,6 +1718,23 @@ def _interpolate_scipy_wrapper(x, y, new_x, method, fill_value=None, bounds_error=bounds_error) new_y = terp(new_x) elif method == 'spline': +<<<<<<< HEAD + + # GH #10633: first attempt +<<<<<<< HEAD + + if not order: + raise ValueError("order needs to be specified and greater than 0") + +======= + if order is None: + raise ValueError("order needs to be specified, use 1, 2, or 3") +>>>>>>> 1561f91... small changes +======= + # GH #10633 + if not order: + raise ValueError("order needs to be specified and greater than 0") +>>>>>>> 5a5407e... updating examples and the bug fix terp = interpolate.UnivariateSpline(x, y, k=order, **kwargs) new_y = terp(new_x) else: diff --git a/pandas/tests/test_generic.py b/pandas/tests/test_generic.py index c1f6045c61d54..b001386466213 100644 --- a/pandas/tests/test_generic.py +++ b/pandas/tests/test_generic.py @@ -799,6 +799,40 @@ def test_nan_interpolate(self): tm._skip_if_no_scipy() result = s.interpolate(method='polynomial', order=1) assert_series_equal(result, expected) +<<<<<<< HEAD +<<<<<<< HEAD + + # GH #10633 +======= + # GH #10633: first attempt +>>>>>>> d992cd0... Updated test +======= + + # GH #10633 +>>>>>>> 5a5407e... updating examples and the bug fix + def test_interpolate_spline(self): + np.random.seed(1) + s = pd.Series(np.arange(10)**2) + s[np.random.randint(0,9,3)] = np.nan + with tm.assertRaises(ValueError): + s.interpolate(method='spline') +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 027a5e7... Updating based on feedback + + def test_interpolate_spline(self): + np.random.seed(1) + t = pd.Series(np.arange(10)**2) + t[np.random.randint(0,9,3)] = np.nan + with tm.assertRaises(ValueError): + t.interpolate(method='spline', order=0) +<<<<<<< HEAD +======= +>>>>>>> d992cd0... Updated test +======= +>>>>>>> 027a5e7... Updating based on feedback + def test_nan_irregular_index(self): s = Series([1, 2, np.nan, 4], index=[1, 3, 5, 9]) @@ -1398,6 +1432,23 @@ def test_no_order(self): s.interpolate(method='polynomial') with tm.assertRaises(ValueError): s.interpolate(method='spline') + +<<<<<<< HEAD +<<<<<<< HEAD +======= + # GH #10633 + def test_order_spline_interpolation(self): + tm._skip_if_no_scipy() + np.random.seed(1) + s = Series(np.arange(10)**2) + s[np.random.randint(0,9,3)] = np.nan + result1 = s.interpolate(method='spline', order=1) + expected1 = s.interpolate(method='spline', order=1) + assert_series_equal(result1, expected1) +>>>>>>> 5a5407e... updating examples and the bug fix +======= +>>>>>>> 027a5e7... Updating based on feedback + def test_spline(self): tm._skip_if_no_scipy() From 01c47470cbb139a0cab7f12f719a4bb97d5e6f37 Mon Sep 17 00:00:00 2001 From: springcoil Date: Fri, 21 Aug 2015 08:39:33 +0200 Subject: [PATCH 2/5] BUG: 10633 - some last errors removed --- pandas/core/common.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/pandas/core/common.py b/pandas/core/common.py index 49bf9cefd9785..48ad299cfd658 100644 --- a/pandas/core/common.py +++ b/pandas/core/common.py @@ -1718,23 +1718,9 @@ def _interpolate_scipy_wrapper(x, y, new_x, method, fill_value=None, bounds_error=bounds_error) new_y = terp(new_x) elif method == 'spline': -<<<<<<< HEAD - - # GH #10633: first attempt -<<<<<<< HEAD - - if not order: - raise ValueError("order needs to be specified and greater than 0") - -======= - if order is None: - raise ValueError("order needs to be specified, use 1, 2, or 3") ->>>>>>> 1561f91... small changes -======= # GH #10633 if not order: raise ValueError("order needs to be specified and greater than 0") ->>>>>>> 5a5407e... updating examples and the bug fix terp = interpolate.UnivariateSpline(x, y, k=order, **kwargs) new_y = terp(new_x) else: From 7c41431a534f47438bb16d0455ab8d8d4ac794c9 Mon Sep 17 00:00:00 2001 From: Spencer Carrucciu Date: Thu, 20 Aug 2015 12:01:54 -0400 Subject: [PATCH 3/5] ENH: pickle support for Period #10439 update legacy_storage for pickles update pickles/msgpack for 0.16.2 Added tests for ABC Types, Issue #10828 TST: #10822, skip tests on windows for odd error message in to_datetime with unicode COMPAT:Allow multi-indexes to be written to excel. (Even though they cannot be read back in.) Closes #10564 DOC: typo A few changes in docs --- doc/source/whatsnew/v0.17.0.txt | 2 -- pandas/tests/test_generic.py | 28 +--------------------------- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/doc/source/whatsnew/v0.17.0.txt b/doc/source/whatsnew/v0.17.0.txt index 8dc38d85e9ff1..ad104303b9dbd 100644 --- a/doc/source/whatsnew/v0.17.0.txt +++ b/doc/source/whatsnew/v0.17.0.txt @@ -612,13 +612,11 @@ Performance Improvements Bug Fixes ~~~~~~~~~ -<<<<<<< HEAD - Bug in ``DataFrame.to_html(index=False)`` renders unnecessary ``name`` row (:issue:`10344`) ======= - Bug in ``DataFrame.to_html(index=False)`` renders unnecessary ``name`` row (:issue:`10344`) ->>>>>>> updating examples and the bug fix - Bug in ``DataFrame.apply`` when function returns categorical series. (:issue:`9573`) - Bug in ``to_datetime`` with invalid dates and formats supplied (:issue:`10154`) - Bug in ``Index.drop_duplicates`` dropping name(s) (:issue:`10115`) diff --git a/pandas/tests/test_generic.py b/pandas/tests/test_generic.py index b001386466213..b08faaa2bb7ad 100644 --- a/pandas/tests/test_generic.py +++ b/pandas/tests/test_generic.py @@ -799,41 +799,15 @@ def test_nan_interpolate(self): tm._skip_if_no_scipy() result = s.interpolate(method='polynomial', order=1) assert_series_equal(result, expected) -<<<<<<< HEAD -<<<<<<< HEAD - - # GH #10633 -======= - # GH #10633: first attempt ->>>>>>> d992cd0... Updated test -======= # GH #10633 ->>>>>>> 5a5407e... updating examples and the bug fix - def test_interpolate_spline(self): - np.random.seed(1) - s = pd.Series(np.arange(10)**2) - s[np.random.randint(0,9,3)] = np.nan - with tm.assertRaises(ValueError): - s.interpolate(method='spline') -<<<<<<< HEAD -<<<<<<< HEAD -======= ->>>>>>> 027a5e7... Updating based on feedback - def test_interpolate_spline(self): np.random.seed(1) t = pd.Series(np.arange(10)**2) t[np.random.randint(0,9,3)] = np.nan with tm.assertRaises(ValueError): t.interpolate(method='spline', order=0) -<<<<<<< HEAD -======= ->>>>>>> d992cd0... Updated test -======= ->>>>>>> 027a5e7... Updating based on feedback - - + def test_nan_irregular_index(self): s = Series([1, 2, np.nan, 4], index=[1, 3, 5, 9]) result = s.interpolate() From 57de3ef286119b903e90e98506de370ca1024be6 Mon Sep 17 00:00:00 2001 From: springcoil Date: Fri, 21 Aug 2015 08:52:40 +0200 Subject: [PATCH 4/5] TST: Changes in test --- pandas/tests/test_generic.py | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/pandas/tests/test_generic.py b/pandas/tests/test_generic.py index b08faaa2bb7ad..d177d9359dfc8 100644 --- a/pandas/tests/test_generic.py +++ b/pandas/tests/test_generic.py @@ -1406,23 +1406,6 @@ def test_no_order(self): s.interpolate(method='polynomial') with tm.assertRaises(ValueError): s.interpolate(method='spline') - -<<<<<<< HEAD -<<<<<<< HEAD -======= - # GH #10633 - def test_order_spline_interpolation(self): - tm._skip_if_no_scipy() - np.random.seed(1) - s = Series(np.arange(10)**2) - s[np.random.randint(0,9,3)] = np.nan - result1 = s.interpolate(method='spline', order=1) - expected1 = s.interpolate(method='spline', order=1) - assert_series_equal(result1, expected1) ->>>>>>> 5a5407e... updating examples and the bug fix -======= ->>>>>>> 027a5e7... Updating based on feedback - def test_spline(self): tm._skip_if_no_scipy() From 822df817f09f0dcebf1041ad3f961b082b37ba2b Mon Sep 17 00:00:00 2001 From: Spencer Carrucciu Date: Thu, 20 Aug 2015 12:01:54 -0400 Subject: [PATCH 5/5] ENH: pickle support for Period #10439 update legacy_storage for pickles update pickles/msgpack for 0.16.2 Added tests for ABC Types, Issue #10828 TST: #10822, skip tests on windows for odd error message in to_datetime with unicode COMPAT:Allow multi-indexes to be written to excel. (Even though they cannot be read back in.) Closes #10564 DOC: typo ENH: pickle support for Period #10439 update legacy_storage for pickles update pickles/msgpack for 0.16.2 Added tests for ABC Types, Issue #10828 TST: #10822, skip tests on windows for odd error message in to_datetime with unicode COMPAT:Allow multi-indexes to be written to excel. (Even though they cannot be read back in.) Closes #10564 DOC: typo A few changes in docs --- pandas/io/tests/generate_legacy_storage_files.py | 11 +++++++++++ pandas/tseries/tests/test_period.py | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/pandas/io/tests/generate_legacy_storage_files.py b/pandas/io/tests/generate_legacy_storage_files.py index 86c5a9e0d7f19..0ec3575be04f6 100644 --- a/pandas/io/tests/generate_legacy_storage_files.py +++ b/pandas/io/tests/generate_legacy_storage_files.py @@ -83,9 +83,20 @@ def create_data(): index=MultiIndex.from_tuples(tuple(zip(*[[1, 1, 2, 2, 2], [3, 4, 3, 4, 5]])), names=['one', 'two'])), dup=Series(np.arange(5).astype(np.float64), index=['A', 'B', 'C', 'D', 'A']), +<<<<<<< HEAD +<<<<<<< HEAD cat=Series(Categorical(['foo', 'bar', 'baz']))) if LooseVersion(pandas.__version__) >= '0.17.0': series['period'] = Series([Period('2000Q1')] * 5) +======= + cat=Series(Categorical(['foo', 'bar', 'baz'])), + per=Series([Period('2000Q1')] * 5)) +>>>>>>> 0525684... ENH: pickle support for Period #10439 +======= + cat=Series(Categorical(['foo', 'bar', 'baz']))) + if LooseVersion(pandas.__version__) >= '0.17.0': + series['period'] = Series([Period('2000Q1')] * 5) +>>>>>>> aa04812... update legacy_storage for pickles mixed_dup_df = DataFrame(data) mixed_dup_df.columns = list("ABCDA") diff --git a/pandas/tseries/tests/test_period.py b/pandas/tseries/tests/test_period.py index eb5c6759bfa45..3a69670f43fb7 100644 --- a/pandas/tseries/tests/test_period.py +++ b/pandas/tseries/tests/test_period.py @@ -2537,7 +2537,17 @@ def test_searchsorted(self): def test_round_trip(self): +<<<<<<< HEAD +<<<<<<< HEAD p = Period('2000Q1') +======= + import pickle + p = Period('2000Q1') + +>>>>>>> 0525684... ENH: pickle support for Period #10439 +======= + p = Period('2000Q1') +>>>>>>> aa04812... update legacy_storage for pickles new_p = self.round_trip_pickle(p) self.assertEqual(new_p, p)