Skip to content

Commit 9ae8499

Browse files
committed
API: Remove set_printoptions/reset_printoptions (:issue:3046)
1 parent ed81ed0 commit 9ae8499

File tree

6 files changed

+8
-88
lines changed

6 files changed

+8
-88
lines changed

doc/source/basics.rst

+5-10
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ Methods like ``replace`` and ``findall`` take regular expressions, too:
983983
s3.str.replace('^.a|dog', 'XX-XX ', case=False)
984984
985985
The method ``match`` returns the groups in a regular expression in one tuple.
986-
Starting in pandas version 0.13, the method ``extract`` is available to
986+
Starting in pandas version 0.13, the method ``extract`` is available to
987987
accomplish this more conveniently.
988988

989989
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.
992992
993993
Series(['a1', 'b2', 'c3']).str.extract('[ab](\d)')
994994
995-
Elements that do not match return ``NaN``. Extracting a regular expression
995+
Elements that do not match return ``NaN``. Extracting a regular expression
996996
with more than one group returns a DataFrame with one column per group.
997997

998998
.. ipython:: python
999999
10001000
Series(['a1', 'b2', 'c3']).str.extract('([ab])(\d)')
10011001
1002-
Elements that do not match return a row of ``NaN``s.
1003-
Thus, a Series of messy strings can be "converted" into a
1004-
like-indexed Series or DataFrame of cleaned-up or more useful strings,
1002+
Elements that do not match return a row of ``NaN``s.
1003+
Thus, a Series of messy strings can be "converted" into a
1004+
like-indexed Series or DataFrame of cleaned-up or more useful strings,
10051005
without necessitating ``get()`` to access tuples or ``re.match`` objects.
10061006

10071007
Named groups like
@@ -1411,11 +1411,6 @@ Console Output Formatting
14111411

14121412
.. _basics.console_output:
14131413

1414-
**Note:** ``set_printoptions``/ ``reset_printoptions`` are now deprecated (but functioning),
1415-
and both, as well as ``set_eng_float_format``, use the options API behind the scenes.
1416-
The corresponding options now live under "print.XYZ", and you can set them directly with
1417-
``get/set_option``.
1418-
14191414
Use the ``set_eng_float_format`` function in the ``pandas.core.common`` module
14201415
to alter the floating-point formatting of pandas objects to produce a particular
14211416
format.

doc/source/release.rst

+1
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ API Changes
235235
on indexes on non ``Float64Index`` will raise a ``TypeError``, e.g. ``Series(range(5))[3.5:4.5]`` (:issue:`263`)
236236
- Make Categorical repr nicer (:issue:`4368`)
237237
- Remove deprecated ``Factor`` (:issue:`3650`)
238+
- Remove ``set_printoptions/reset_printoptions`` (:issue:``3046``)
238239

239240
Internal Refactoring
240241
~~~~~~~~~~~~~~~~~~~~

pandas/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
# XXX: HACK for NumPy 1.5.1 to suppress warnings
2222
try:
2323
np.seterr(all='ignore')
24-
# np.set_printoptions(suppress=True)
2524
except Exception: # pragma: no cover
2625
pass
2726

pandas/core/api.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
from pandas.core.algorithms import factorize, match, unique, value_counts
77
from pandas.core.common import isnull, notnull
88
from pandas.core.categorical import Categorical
9-
from pandas.core.format import (set_printoptions, reset_printoptions,
10-
set_eng_float_format)
9+
from pandas.core.format import set_eng_float_format
1110
from pandas.core.index import Index, Int64Index, Float64Index, MultiIndex
1211

1312
from pandas.core.series import Series, TimeSeries

pandas/core/format.py

+1-73
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
multiindex key at each row, default True
5050
justify : {'left', 'right'}, default None
5151
Left or right-justify the column labels. If None uses the option from
52-
the print configuration (controlled by set_printoptions), 'right' out
52+
the print configuration (controlled by set_option), 'right' out
5353
of the box.
5454
index_names : bool, optional
5555
Prints the names of the indexes, default True
@@ -1669,78 +1669,6 @@ def _has_names(index):
16691669
#------------------------------------------------------------------------------
16701670
# Global formatting options
16711671

1672-
1673-
def set_printoptions(precision=None, column_space=None, max_rows=None,
1674-
max_columns=None, colheader_justify=None,
1675-
max_colwidth=None, notebook_repr_html=None,
1676-
date_dayfirst=None, date_yearfirst=None,
1677-
pprint_nest_depth=None, multi_sparse=None, encoding=None):
1678-
"""
1679-
Alter default behavior of DataFrame.toString
1680-
1681-
precision : int
1682-
Floating point output precision (number of significant digits). This is
1683-
only a suggestion
1684-
column_space : int
1685-
Default space for DataFrame columns, defaults to 12
1686-
max_rows : int
1687-
max_columns : int
1688-
max_rows and max_columns are used in __repr__() methods to decide if
1689-
to_string() or info() is used to render an object to a string.
1690-
Either one, or both can be set to 0 (experimental). Pandas will figure
1691-
out how big the terminal is and will not display more rows or/and
1692-
columns that can fit on it.
1693-
colheader_justify
1694-
notebook_repr_html : boolean
1695-
When True (default), IPython notebook will use html representation for
1696-
pandas objects (if it is available).
1697-
date_dayfirst : boolean
1698-
When True, prints and parses dates with the day first, eg 20/01/2005
1699-
date_yearfirst : boolean
1700-
When True, prints and parses dates with the year first, eg 2005/01/20
1701-
pprint_nest_depth : int
1702-
Defaults to 3.
1703-
Controls the number of nested levels to process when pretty-printing
1704-
nested sequences.
1705-
multi_sparse : boolean
1706-
Default True, "sparsify" MultiIndex display (don't display repeated
1707-
elements in outer levels within groups)
1708-
"""
1709-
import warnings
1710-
warnings.warn("set_printoptions is deprecated, use set_option instead",
1711-
FutureWarning)
1712-
if precision is not None:
1713-
set_option("display.precision", precision)
1714-
if column_space is not None:
1715-
set_option("display.column_space", column_space)
1716-
if max_rows is not None:
1717-
set_option("display.max_rows", max_rows)
1718-
if max_colwidth is not None:
1719-
set_option("display.max_colwidth", max_colwidth)
1720-
if max_columns is not None:
1721-
set_option("display.max_columns", max_columns)
1722-
if colheader_justify is not None:
1723-
set_option("display.colheader_justify", colheader_justify)
1724-
if notebook_repr_html is not None:
1725-
set_option("display.notebook_repr_html", notebook_repr_html)
1726-
if date_dayfirst is not None:
1727-
set_option("display.date_dayfirst", date_dayfirst)
1728-
if date_yearfirst is not None:
1729-
set_option("display.date_yearfirst", date_yearfirst)
1730-
if pprint_nest_depth is not None:
1731-
set_option("display.pprint_nest_depth", pprint_nest_depth)
1732-
if multi_sparse is not None:
1733-
set_option("display.multi_sparse", multi_sparse)
1734-
if encoding is not None:
1735-
set_option("display.encoding", encoding)
1736-
1737-
1738-
def reset_printoptions():
1739-
import warnings
1740-
warnings.warn("reset_printoptions is deprecated, use reset_option instead",
1741-
FutureWarning)
1742-
reset_option("^display\.")
1743-
17441672
_initial_defencoding = None
17451673
def detect_console_encoding():
17461674
"""

pandas/tests/test_config.py

-2
Original file line numberDiff line numberDiff line change
@@ -437,5 +437,3 @@ def f3(key):
437437
options.c = 1
438438
self.assertEqual(len(holder), 1)
439439

440-
# fmt.reset_printoptions and fmt.set_printoptions were altered
441-
# to use core.config, test_format exercises those paths.

0 commit comments

Comments
 (0)