From 9ae8499df4bd0ed792d657d3e72dd84e2e02fea8 Mon Sep 17 00:00:00 2001 From: jreback Date: Thu, 26 Sep 2013 16:46:41 -0400 Subject: [PATCH 1/2] API: Remove set_printoptions/reset_printoptions (:issue:3046) --- doc/source/basics.rst | 15 +++----- doc/source/release.rst | 1 + pandas/__init__.py | 1 - pandas/core/api.py | 3 +- pandas/core/format.py | 74 +------------------------------------ pandas/tests/test_config.py | 2 - 6 files changed, 8 insertions(+), 88 deletions(-) diff --git a/doc/source/basics.rst b/doc/source/basics.rst index 7d2555e8cba81..b167b00b58ef1 100644 --- a/doc/source/basics.rst +++ b/doc/source/basics.rst @@ -983,7 +983,7 @@ Methods like ``replace`` and ``findall`` take regular expressions, too: s3.str.replace('^.a|dog', 'XX-XX ', case=False) The method ``match`` returns the groups in a regular expression in one tuple. - Starting in pandas version 0.13, the method ``extract`` is available to + Starting in pandas version 0.13, the method ``extract`` is available to accomplish this more conveniently. Extracting a regular expression with one group returns a Series of strings. @@ -992,16 +992,16 @@ Extracting a regular expression with one group returns a Series of strings. Series(['a1', 'b2', 'c3']).str.extract('[ab](\d)') -Elements that do not match return ``NaN``. Extracting a regular expression +Elements that do not match return ``NaN``. Extracting a regular expression with more than one group returns a DataFrame with one column per group. .. ipython:: python Series(['a1', 'b2', 'c3']).str.extract('([ab])(\d)') -Elements that do not match return a row of ``NaN``s. -Thus, a Series of messy strings can be "converted" into a -like-indexed Series or DataFrame of cleaned-up or more useful strings, +Elements that do not match return a row of ``NaN``s. +Thus, a Series of messy strings can be "converted" into a +like-indexed Series or DataFrame of cleaned-up or more useful strings, without necessitating ``get()`` to access tuples or ``re.match`` objects. Named groups like @@ -1411,11 +1411,6 @@ Console Output Formatting .. _basics.console_output: -**Note:** ``set_printoptions``/ ``reset_printoptions`` are now deprecated (but functioning), -and both, as well as ``set_eng_float_format``, use the options API behind the scenes. -The corresponding options now live under "print.XYZ", and you can set them directly with -``get/set_option``. - Use the ``set_eng_float_format`` function in the ``pandas.core.common`` module to alter the floating-point formatting of pandas objects to produce a particular format. diff --git a/doc/source/release.rst b/doc/source/release.rst index 8ba0574df97cb..e1067cb8c6d09 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -235,6 +235,7 @@ API Changes on indexes on non ``Float64Index`` will raise a ``TypeError``, e.g. ``Series(range(5))[3.5:4.5]`` (:issue:`263`) - Make Categorical repr nicer (:issue:`4368`) - Remove deprecated ``Factor`` (:issue:`3650`) + - Remove ``set_printoptions/reset_printoptions`` (:issue:``3046``) Internal Refactoring ~~~~~~~~~~~~~~~~~~~~ diff --git a/pandas/__init__.py b/pandas/__init__.py index ddd4cd49e6ec6..803cda264b250 100644 --- a/pandas/__init__.py +++ b/pandas/__init__.py @@ -21,7 +21,6 @@ # XXX: HACK for NumPy 1.5.1 to suppress warnings try: np.seterr(all='ignore') - # np.set_printoptions(suppress=True) except Exception: # pragma: no cover pass diff --git a/pandas/core/api.py b/pandas/core/api.py index 2b4063eae1f74..36081cc34cc3a 100644 --- a/pandas/core/api.py +++ b/pandas/core/api.py @@ -6,8 +6,7 @@ from pandas.core.algorithms import factorize, match, unique, value_counts from pandas.core.common import isnull, notnull from pandas.core.categorical import Categorical -from pandas.core.format import (set_printoptions, reset_printoptions, - set_eng_float_format) +from pandas.core.format import set_eng_float_format from pandas.core.index import Index, Int64Index, Float64Index, MultiIndex from pandas.core.series import Series, TimeSeries diff --git a/pandas/core/format.py b/pandas/core/format.py index be6ad4d2bc5ef..190ef3fb5f1ab 100644 --- a/pandas/core/format.py +++ b/pandas/core/format.py @@ -49,7 +49,7 @@ multiindex key at each row, default True justify : {'left', 'right'}, default None Left or right-justify the column labels. If None uses the option from - the print configuration (controlled by set_printoptions), 'right' out + the print configuration (controlled by set_option), 'right' out of the box. index_names : bool, optional Prints the names of the indexes, default True @@ -1669,78 +1669,6 @@ def _has_names(index): #------------------------------------------------------------------------------ # Global formatting options - -def set_printoptions(precision=None, column_space=None, max_rows=None, - max_columns=None, colheader_justify=None, - max_colwidth=None, notebook_repr_html=None, - date_dayfirst=None, date_yearfirst=None, - pprint_nest_depth=None, multi_sparse=None, encoding=None): - """ - Alter default behavior of DataFrame.toString - - precision : int - Floating point output precision (number of significant digits). This is - only a suggestion - column_space : int - Default space for DataFrame columns, defaults to 12 - max_rows : int - max_columns : int - max_rows and max_columns are used in __repr__() methods to decide if - to_string() or info() is used to render an object to a string. - Either one, or both can be set to 0 (experimental). Pandas will figure - out how big the terminal is and will not display more rows or/and - columns that can fit on it. - colheader_justify - notebook_repr_html : boolean - When True (default), IPython notebook will use html representation for - pandas objects (if it is available). - date_dayfirst : boolean - When True, prints and parses dates with the day first, eg 20/01/2005 - date_yearfirst : boolean - When True, prints and parses dates with the year first, eg 2005/01/20 - pprint_nest_depth : int - Defaults to 3. - Controls the number of nested levels to process when pretty-printing - nested sequences. - multi_sparse : boolean - Default True, "sparsify" MultiIndex display (don't display repeated - elements in outer levels within groups) - """ - import warnings - warnings.warn("set_printoptions is deprecated, use set_option instead", - FutureWarning) - if precision is not None: - set_option("display.precision", precision) - if column_space is not None: - set_option("display.column_space", column_space) - if max_rows is not None: - set_option("display.max_rows", max_rows) - if max_colwidth is not None: - set_option("display.max_colwidth", max_colwidth) - if max_columns is not None: - set_option("display.max_columns", max_columns) - if colheader_justify is not None: - set_option("display.colheader_justify", colheader_justify) - if notebook_repr_html is not None: - set_option("display.notebook_repr_html", notebook_repr_html) - if date_dayfirst is not None: - set_option("display.date_dayfirst", date_dayfirst) - if date_yearfirst is not None: - set_option("display.date_yearfirst", date_yearfirst) - if pprint_nest_depth is not None: - set_option("display.pprint_nest_depth", pprint_nest_depth) - if multi_sparse is not None: - set_option("display.multi_sparse", multi_sparse) - if encoding is not None: - set_option("display.encoding", encoding) - - -def reset_printoptions(): - import warnings - warnings.warn("reset_printoptions is deprecated, use reset_option instead", - FutureWarning) - reset_option("^display\.") - _initial_defencoding = None def detect_console_encoding(): """ diff --git a/pandas/tests/test_config.py b/pandas/tests/test_config.py index ed6f641cbcb2c..80a3fe9be7003 100644 --- a/pandas/tests/test_config.py +++ b/pandas/tests/test_config.py @@ -437,5 +437,3 @@ def f3(key): options.c = 1 self.assertEqual(len(holder), 1) -# fmt.reset_printoptions and fmt.set_printoptions were altered -# to use core.config, test_format exercises those paths. From ba0097346aa5eace0510698fde26a42cd8a0b444 Mon Sep 17 00:00:00 2001 From: jreback Date: Thu, 26 Sep 2013 18:13:20 -0400 Subject: [PATCH 2/2] API: remove deprecated _verbose_info (GH3215) --- doc/source/release.rst | 3 ++- doc/source/v0.13.0.txt | 4 ++++ pandas/core/frame.py | 7 ------- pandas/sparse/frame.py | 1 - 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/doc/source/release.rst b/doc/source/release.rst index e1067cb8c6d09..8c72235297bd0 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -235,7 +235,8 @@ API Changes on indexes on non ``Float64Index`` will raise a ``TypeError``, e.g. ``Series(range(5))[3.5:4.5]`` (:issue:`263`) - Make Categorical repr nicer (:issue:`4368`) - Remove deprecated ``Factor`` (:issue:`3650`) - - Remove ``set_printoptions/reset_printoptions`` (:issue:``3046``) + - Remove deprecated ``set_printoptions/reset_printoptions`` (:issue:``3046``) + - Remove deprecated ``_verbose_info`` (:issue:`3215`) Internal Refactoring ~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/source/v0.13.0.txt b/doc/source/v0.13.0.txt index 13aff4d21e802..b1c40fe3b2ced 100644 --- a/doc/source/v0.13.0.txt +++ b/doc/source/v0.13.0.txt @@ -68,6 +68,10 @@ API changes df1 and df2 s1 and s2 + - Remove deprecated ``Factor`` (:issue:`3650`) + - Remove deprecated ``set_printoptions/reset_printoptions`` (:issue:``3046``) + - Remove deprecated ``_verbose_info`` (:issue:`3215`) + Indexing API Changes ~~~~~~~~~~~~~~~~~~~~ diff --git a/pandas/core/frame.py b/pandas/core/frame.py index c98790fdc38ff..7b9a75753136e 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -371,7 +371,6 @@ class DataFrame(NDFrame): read_csv / read_table / read_clipboard """ _auto_consolidate = True - _verbose_info = True @property def _constructor(self): @@ -554,12 +553,6 @@ def _init_ndarray(self, values, index, columns, dtype=None, return create_block_manager_from_blocks([values.T], [columns, index]) - @property - def _verbose_info(self): - warnings.warn('The _verbose_info property will be removed in version ' - '0.13. please use "max_info_rows"', FutureWarning) - return get_option('display.max_info_rows') is None - @property def axes(self): return [self.index, self.columns] diff --git a/pandas/sparse/frame.py b/pandas/sparse/frame.py index a1b630dedaaab..53fabb0160a88 100644 --- a/pandas/sparse/frame.py +++ b/pandas/sparse/frame.py @@ -46,7 +46,6 @@ class SparseDataFrame(DataFrame): Default fill_value for converting Series to SparseSeries. Will not override SparseSeries passed in """ - _verbose_info = False _constructor_sliced = SparseSeries _subtyp = 'sparse_frame'