diff --git a/doc/source/release.rst b/doc/source/release.rst index f7b47b06ef841..fce5f2f93e68b 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -198,7 +198,9 @@ Deprecations will not be supported in a future release (:issue:`6645`) - Indexers will warn ``FutureWarning`` when used with a scalar indexer and - a non-floating point Index (:issue:`4892`) + a non-floating point Index (:issue:`4892`, :issue:`6960`) + +- Numpy 1.9 compat w.r.t. deprecation warnings (:issue:`6960`) - :meth:`Panel.shift` now has a function signature that matches :meth:`DataFrame.shift`. The old positional argument ``lags`` has been changed to a keyword argument diff --git a/doc/source/v0.14.0.txt b/doc/source/v0.14.0.txt index dd6a21ccecf55..acacbd1c0b43c 100644 --- a/doc/source/v0.14.0.txt +++ b/doc/source/v0.14.0.txt @@ -392,7 +392,7 @@ Deprecations will not be supported in a future release (:issue:`6645`) - Indexers will warn ``FutureWarning`` when used with a scalar indexer and - a non-floating point Index (:issue:`4892`) + a non-floating point Index (:issue:`4892`, :issue:`6960`) .. code-block:: python @@ -401,17 +401,25 @@ Deprecations pandas/core/index.py:469: FutureWarning: scalar indexers for index type Int64Index should be integers and not floating point Out[1]: 1 - In [5]: Series(1,np.arange(5)).iloc[3.0] + In [2]: Series(1,np.arange(5)).iloc[3.0] pandas/core/index.py:469: FutureWarning: scalar indexers for index type Int64Index should be integers and not floating point - Out[5]: 1 + Out[2]: 1 - # these are Float64Indexes, so integer or floating point is acceptable - In [3]: Series(1,np.arange(5.))[3] - Out[3]: 1 + In [3]: Series(1,np.arange(5)).iloc[3.0:4] + pandas/core/index.py:527: FutureWarning: slice indexers when using iloc should be integers and not floating point + Out[3]: + 3 1 + dtype: int64 - In [4]: Series(1,np.arange(5.))[3.0] + # these are Float64Indexes, so integer or floating point is acceptable + In [4]: Series(1,np.arange(5.))[3] Out[4]: 1 + In [5]: Series(1,np.arange(5.))[3.0] + Out[6]: 1 + +- Numpy 1.9 compat w.r.t. deprecation warnings (:issue:`6960`) + - :meth:`Panel.shift` now has a function signature that matches :meth:`DataFrame.shift`. The old positional argument ``lags`` has been changed to a keyword argument ``periods`` with a default value of 1. A ``FutureWarning`` is raised if the @@ -484,13 +492,13 @@ Enhancements - Added ``how`` option to rolling-moment functions to dictate how to handle resampling; :func:``rolling_max`` defaults to max, :func:``rolling_min`` defaults to min, and all others default to mean (:issue:`6297`) - ``CustomBuisnessMonthBegin`` and ``CustomBusinessMonthEnd`` are now available (:issue:`6866`) -- :meth:`Series.quantile` and :meth:`DataFrame.quantile` now accept an array of +- :meth:`Series.quantile` and :meth:`DataFrame.quantile` now accept an array of quantiles. - ``pivot_table`` can now accept ``Grouper`` by ``index`` and ``columns`` keywords (:issue:`6913`) .. ipython:: python - import datetime + import datetime df = DataFrame({ 'Branch' : 'A A A A A B'.split(), 'Buyer': 'Carl Mark Carl Carl Joe Joe'.split(), diff --git a/pandas/core/config.py b/pandas/core/config.py index f2f932e39759a..ebac3d40221e7 100644 --- a/pandas/core/config.py +++ b/pandas/core/config.py @@ -140,7 +140,7 @@ def _describe_option(pat='', _print_desc=True): return s -def _reset_option(pat): +def _reset_option(pat, silent=False): keys = _select_options(pat) @@ -154,7 +154,7 @@ def _reset_option(pat): 'value') for k in keys: - _set_option(k, _registered_options[k].defval) + _set_option(k, _registered_options[k].defval, silent=silent) def get_default_val(pat): @@ -361,7 +361,7 @@ def __enter__(self): def __exit__(self, *args): if self.undo: for pat, val in self.undo: - _set_option(pat, val) + _set_option(pat, val, silent=True) def register_option(key, defval, doc='', validator=None, cb=None): @@ -567,6 +567,7 @@ def _warn_if_deprecated(key): d = _get_deprecated_option(key) if d: if d.msg: + print(d.msg) warnings.warn(d.msg, DeprecationWarning) else: msg = "'%s' is deprecated" % key diff --git a/pandas/tests/test_format.py b/pandas/tests/test_format.py index aee1fad6c3253..3404e4ddb7d44 100644 --- a/pandas/tests/test_format.py +++ b/pandas/tests/test_format.py @@ -104,8 +104,7 @@ def test_eng_float_formatter(self): fmt.set_eng_float_format(accuracy=0) repr(self.frame) - - fmt.reset_option('^display.') + self.reset_display_options() def test_repr_tuples(self): buf = StringIO() @@ -1034,7 +1033,7 @@ def test_to_string_no_index(self): assert(df_s == expected) def test_to_string_float_formatting(self): - fmt.reset_option('^display.') + self.reset_display_options() fmt.set_option('display.precision', 6, 'display.column_space', 12, 'display.notebook_repr_html', False) @@ -1065,7 +1064,7 @@ def test_to_string_float_formatting(self): '1 0.253') assert(df_s == expected) - fmt.reset_option('^display.') + self.reset_display_options() self.assertEqual(get_option("display.precision"), 7) df = DataFrame({'x': [1e9, 0.2512]}) @@ -1157,7 +1156,7 @@ def test_to_string_index_formatter(self): self.assertEqual(rs, xp) def test_to_string_left_justify_cols(self): - fmt.reset_option('^display.') + self.reset_display_options() df = DataFrame({'x': [3234, 0.253]}) df_s = df.to_string(justify='left') expected = (' x \n' @@ -1166,7 +1165,7 @@ def test_to_string_left_justify_cols(self): assert(df_s == expected) def test_to_string_format_na(self): - fmt.reset_option('^display.') + self.reset_display_options() df = DataFrame({'A': [np.nan, -1, -2.1234, 3, 4], 'B': [np.nan, 'foo', 'foooo', 'fooooo', 'bar']}) result = df.to_string() @@ -1434,14 +1433,14 @@ def test_repr_html(self): fmt.set_option('display.notebook_repr_html', False) self.frame._repr_html_() - fmt.reset_option('^display.') + self.reset_display_options() df = DataFrame([[1, 2], [3, 4]]) self.assertTrue('2 rows' in df._repr_html_()) fmt.set_option('display.show_dimensions', False) self.assertFalse('2 rows' in df._repr_html_()) - fmt.reset_option('^display.') + self.reset_display_options() def test_repr_html_wide(self): row = lambda l, k: [tm.rands(k) for _ in range(l)] @@ -1580,7 +1579,7 @@ def get_ipython(): repstr = self.frame._repr_html_() self.assertIn('class', repstr) # info fallback - fmt.reset_option('^display.') + self.reset_display_options() def test_to_html_with_classes(self): df = pandas.DataFrame() @@ -2092,7 +2091,7 @@ def test_eng_float_formatter(self): '3 1E+06') self.assertEqual(result, expected) - fmt.reset_option('^display.') + self.reset_display_options() def compare(self, formatter, input, output): formatted_input = formatter(input) diff --git a/pandas/tests/test_frame.py b/pandas/tests/test_frame.py index 11c065a52d78e..d96fbb9ec05d7 100644 --- a/pandas/tests/test_frame.py +++ b/pandas/tests/test_frame.py @@ -4355,7 +4355,7 @@ def test_repr_dimensions(self): fmt.set_option('display.show_dimensions', False) self.assertFalse("2 rows x 2 columns" in repr(df)) - fmt.reset_option('^display\.') + self.reset_display_options() @slow def test_repr_big(self): @@ -4391,7 +4391,7 @@ def test_repr_unsortable(self): fmt.set_option('display.max_rows', 1000, 'display.max_columns', 1000) repr(self.frame) - fmt.reset_option('^display\.') + self.reset_display_options() warnings.filters = warn_filters diff --git a/pandas/tests/test_index.py b/pandas/tests/test_index.py index ecb09ac395417..c3cea9cfbe0a0 100644 --- a/pandas/tests/test_index.py +++ b/pandas/tests/test_index.py @@ -2145,7 +2145,7 @@ def test_format_sparse_config(self): result = self.index.format() self.assertEqual(result[1], 'foo two') - pd.reset_option("^display\.") + self.reset_display_options() warnings.filters = warn_filters diff --git a/pandas/util/testing.py b/pandas/util/testing.py index 95fcc7848c433..0d1f2118fbe88 100644 --- a/pandas/util/testing.py +++ b/pandas/util/testing.py @@ -69,6 +69,10 @@ def setUpClass(cls): def tearDownClass(cls): pass + def reset_display_options(self): + # reset the display options + pd.reset_option('^display.',silent=True) + def assert_numpy_array_equal(self, np_array, assert_equal): if np.array_equal(np_array, assert_equal): return