Skip to content

Commit c010904

Browse files
author
y-p
committed
REF: rename option key "print" to "display"
print is a python keyword, bad choice.
1 parent 90cddee commit c010904

File tree

12 files changed

+99
-96
lines changed

12 files changed

+99
-96
lines changed

doc/source/basics.rst

+17-14
Original file line numberDiff line numberDiff line change
@@ -1058,25 +1058,28 @@ and they are:
10581058

10591059
**Note:** developers can check out pandas/core/config.py for more info.
10601060

1061-
Options have a full "dotted-style", case-insensitive name (e.g. ``print.max_rows``),
1061+
Options have a full "dotted-style", case-insensitive name (e.g. ``display.max_rows``),
10621062
but all of the functions above accept a regexp pattern (``re.search`` style) as argument,
10631063
so passing in a substring will work - as long as it is unambiguous :
10641064

10651065
.. ipython:: python
10661066
1067-
get_option("print.max_rows")
1068-
set_option("print.max_rows",101)
1069-
get_option("print.max_rows")
1067+
get_option("display.max_rows")
1068+
set_option("display.max_rows",101)
1069+
get_option("display.max_rows")
10701070
set_option("max_r",102)
1071-
get_option("print.max_rows")
1071+
get_option("display.max_rows")
10721072
10731073
1074-
However, the following will **not work** because it matches multiple option names, e.g.``print.max_colwidth``, ``print.max_rows``, ``print.max_columns``:
1074+
However, the following will **not work** because it matches multiple option names, e.g.``display.max_colwidth``, ``display.max_rows``, ``display.max_columns``:
10751075

10761076
.. ipython:: python
10771077
:okexcept:
10781078
1079-
get_option("print.max_")
1079+
try:
1080+
get_option("display.max_")
1081+
except KeyError as e:
1082+
print(e)
10801083
10811084
10821085
**Note:** Using this form of convenient shorthand may make your code break if new options with similar names are added in future versions.
@@ -1103,23 +1106,23 @@ All options also have a default value, and you can use the ``reset_option`` to d
11031106
.. ipython:: python
11041107
:suppress:
11051108
1106-
reset_option("print.max_rows")
1109+
reset_option("display.max_rows")
11071110
11081111
11091112
.. ipython:: python
11101113
1111-
get_option("print.max_rows")
1112-
set_option("print.max_rows",999)
1113-
get_option("print.max_rows")
1114-
reset_option("print.max_rows")
1115-
get_option("print.max_rows")
1114+
get_option("display.max_rows")
1115+
set_option("display.max_rows",999)
1116+
get_option("display.max_rows")
1117+
reset_option("display.max_rows")
1118+
get_option("display.max_rows")
11161119
11171120
11181121
and you also set multiple options at once:
11191122

11201123
.. ipython:: python
11211124
1122-
reset_option("^print\.")
1125+
reset_option("^display\.")
11231126
11241127
11251128

doc/source/v0.10.0.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,11 @@ Convenience methods ``ffill`` and ``bfill`` have been added:
160160
arguments. print all registered options.
161161

162162
Note: ``set_printoptions``/ ``reset_printoptions`` are now deprecated (but
163-
functioning), the print options now live under "print.XYZ". For example:
163+
functioning), the print options now live under "display.XYZ". For example:
164164

165165
.. ipython:: python
166166

167-
get_option("print.max_rows")
167+
get_option("display.max_rows")
168168

169169
- to_string() methods now always return unicode strings (GH2224_).
170170

@@ -284,7 +284,7 @@ Updated PyTables Support
284284
df['string'] = 'string'
285285
df['int'] = 1
286286
store.append('df',df)
287-
df1 = store.select('df')
287+
df1 = store.select('df')
288288
df1
289289
df1.get_dtype_counts()
290290

pandas/core/common.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,7 @@ def in_qtconsole():
12131213
# 2) If you need to send something to the console, use console_encode().
12141214
#
12151215
# console_encode() should (hopefully) choose the right encoding for you
1216-
# based on the encoding set in option "print.encoding"
1216+
# based on the encoding set in option "display.encoding"
12171217
#
12181218
# 3) if you need to write something out to file, use
12191219
# pprint_thing_encoded(encoding).
@@ -1272,10 +1272,10 @@ def pprint_thing(thing, _nest_lvl=0, escape_chars=None):
12721272
hasattr(thing,'next'):
12731273
return unicode(thing)
12741274
elif (isinstance(thing, dict) and
1275-
_nest_lvl < get_option("print.pprint_nest_depth")):
1275+
_nest_lvl < get_option("display.pprint_nest_depth")):
12761276
result = _pprint_dict(thing, _nest_lvl)
12771277
elif _is_sequence(thing) and _nest_lvl < \
1278-
get_option("print.pprint_nest_depth"):
1278+
get_option("display.pprint_nest_depth"):
12791279
result = _pprint_seq(thing, _nest_lvl, escape_chars=escape_chars)
12801280
else:
12811281
# when used internally in the package, everything
@@ -1313,8 +1313,8 @@ def console_encode(object, **kwds):
13131313
this is the sanctioned way to prepare something for
13141314
sending *to the console*, it delegates to pprint_thing() to get
13151315
a unicode representation of the object relies on the global encoding
1316-
set in print.encoding. Use this everywhere
1316+
set in display.encoding. Use this everywhere
13171317
where you output to the console.
13181318
"""
13191319
return pprint_thing_encoded(object,
1320-
get_option("print.encoding"))
1320+
get_option("display.encoding"))

pandas/core/config_init.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
###########################################
19-
# options from the "print" namespace
19+
# options from the "display" namespace
2020

2121
pc_precision_doc="""
2222
: int
@@ -121,7 +121,7 @@
121121
When printing wide DataFrames, this is the width of each line.
122122
"""
123123

124-
with cf.config_prefix('print'):
124+
with cf.config_prefix('display'):
125125
cf.register_option('precision', 7, pc_precision_doc, validator=is_int)
126126
cf.register_option('float_format', None, float_format_doc)
127127
cf.register_option('column_space', 12, validator=is_int)

pandas/core/format.py

+26-26
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def __init__(self, series, buf=None, header=True, length=True,
7474
self.header = header
7575

7676
if float_format is None:
77-
float_format = get_option("print.float_format")
77+
float_format = get_option("display.float_format")
7878
self.float_format = float_format
7979

8080
def _get_footer(self):
@@ -151,7 +151,7 @@ def _encode_diff_func():
151151
if py3compat.PY3: # pragma: no cover
152152
_encode_diff = lambda x: 0
153153
else:
154-
encoding = get_option("print.encoding")
154+
encoding = get_option("display.encoding")
155155
def _encode_diff(x):
156156
return len(x) - len(x.decode(encoding))
157157

@@ -162,7 +162,7 @@ def _strlen_func():
162162
if py3compat.PY3: # pragma: no cover
163163
_strlen = len
164164
else:
165-
encoding = get_option("print.encoding")
165+
encoding = get_option("display.encoding")
166166
def _strlen(x):
167167
try:
168168
return len(x.decode(encoding))
@@ -208,7 +208,7 @@ def __init__(self, frame, buf=None, columns=None, col_space=None,
208208
self.show_index_names = index_names
209209

210210
if sparsify is None:
211-
sparsify = get_option("print.multi_sparse")
211+
sparsify = get_option("display.multi_sparse")
212212

213213
self.sparsify = sparsify
214214

@@ -221,7 +221,7 @@ def __init__(self, frame, buf=None, columns=None, col_space=None,
221221
self.line_width = line_width
222222

223223
if justify is None:
224-
self.justify = get_option("print.colheader_justify")
224+
self.justify = get_option("display.colheader_justify")
225225
else:
226226
self.justify = justify
227227

@@ -1005,13 +1005,13 @@ def format_array(values, formatter, float_format=None, na_rep='NaN',
10051005
fmt_klass = GenericArrayFormatter
10061006

10071007
if space is None:
1008-
space = get_option("print.column_space")
1008+
space = get_option("display.column_space")
10091009

10101010
if float_format is None:
1011-
float_format = get_option("print.float_format")
1011+
float_format = get_option("display.float_format")
10121012

10131013
if digits is None:
1014-
digits = get_option("print.precision")
1014+
digits = get_option("display.precision")
10151015

10161016
fmt_obj = fmt_klass(values, digits, na_rep=na_rep,
10171017
float_format=float_format,
@@ -1039,9 +1039,9 @@ def get_result(self):
10391039

10401040
def _format_strings(self):
10411041
if self.float_format is None:
1042-
float_format = get_option("print.float_format")
1042+
float_format = get_option("display.float_format")
10431043
if float_format is None:
1044-
fmt_str = '%% .%dg' % get_option("print.precision")
1044+
fmt_str = '%% .%dg' % get_option("display.precision")
10451045
float_format = lambda x: fmt_str % x
10461046
else:
10471047
float_format = self.float_format
@@ -1167,7 +1167,7 @@ def _make_fixed_width(strings, justify='right', minimum=None):
11671167
if minimum is not None:
11681168
max_len = max(minimum, max_len)
11691169

1170-
conf_max = get_option("print.max_colwidth")
1170+
conf_max = get_option("display.max_colwidth")
11711171
if conf_max is not None and max_len > conf_max:
11721172
max_len = conf_max
11731173

@@ -1281,35 +1281,35 @@ def set_printoptions(precision=None, column_space=None, max_rows=None,
12811281
warnings.warn("set_printoptions is deprecated, use set_option instead",
12821282
FutureWarning)
12831283
if precision is not None:
1284-
set_option("print.precision", precision)
1284+
set_option("display.precision", precision)
12851285
if column_space is not None:
1286-
set_option("print.column_space", column_space)
1286+
set_option("display.column_space", column_space)
12871287
if max_rows is not None:
1288-
set_option("print.max_rows", max_rows)
1288+
set_option("display.max_rows", max_rows)
12891289
if max_colwidth is not None:
1290-
set_option("print.max_colwidth", max_colwidth)
1290+
set_option("display.max_colwidth", max_colwidth)
12911291
if max_columns is not None:
1292-
set_option("print.max_columns", max_columns)
1292+
set_option("display.max_columns", max_columns)
12931293
if colheader_justify is not None:
1294-
set_option("print.colheader_justify", colheader_justify)
1294+
set_option("display.colheader_justify", colheader_justify)
12951295
if notebook_repr_html is not None:
1296-
set_option("print.notebook_repr_html", notebook_repr_html)
1296+
set_option("display.notebook_repr_html", notebook_repr_html)
12971297
if date_dayfirst is not None:
1298-
set_option("print.date_dayfirst", date_dayfirst)
1298+
set_option("display.date_dayfirst", date_dayfirst)
12991299
if date_yearfirst is not None:
1300-
set_option("print.date_yearfirst", date_yearfirst)
1300+
set_option("display.date_yearfirst", date_yearfirst)
13011301
if pprint_nest_depth is not None:
1302-
set_option("print.pprint_nest_depth", pprint_nest_depth)
1302+
set_option("display.pprint_nest_depth", pprint_nest_depth)
13031303
if multi_sparse is not None:
1304-
set_option("print.multi_sparse", multi_sparse)
1304+
set_option("display.multi_sparse", multi_sparse)
13051305
if encoding is not None:
1306-
set_option("print.encoding", encoding)
1306+
set_option("display.encoding", encoding)
13071307

13081308
def reset_printoptions():
13091309
import warnings
13101310
warnings.warn("reset_printoptions is deprecated, use reset_option instead",
13111311
FutureWarning)
1312-
reset_option("^print\.")
1312+
reset_option("^display\.")
13131313

13141314
def detect_console_encoding():
13151315
"""
@@ -1441,8 +1441,8 @@ def set_eng_float_format(precision=None, accuracy=3, use_eng_prefix=False):
14411441
"being renamed to 'accuracy'", FutureWarning)
14421442
accuracy = precision
14431443

1444-
set_option("print.float_format", EngFormatter(accuracy, use_eng_prefix))
1445-
set_option("print.column_space", max(12, accuracy + 9))
1444+
set_option("display.float_format", EngFormatter(accuracy, use_eng_prefix))
1445+
set_option("display.column_space", max(12, accuracy + 9))
14461446

14471447
def _put_lines(buf, lines):
14481448
if any(isinstance(x, unicode) for x in lines):

pandas/core/frame.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -594,10 +594,10 @@ def _need_info_repr_(self):
594594
terminal_width, terminal_height = 100, 100
595595
else:
596596
terminal_width, terminal_height = get_terminal_size()
597-
max_rows = (terminal_height if get_option("print.max_rows") == 0
598-
else get_option("print.max_rows"))
599-
max_columns = get_option("print.max_columns")
600-
expand_repr = get_option("print.expand_frame_repr")
597+
max_rows = (terminal_height if get_option("display.max_rows") == 0
598+
else get_option("display.max_rows"))
599+
max_columns = get_option("display.max_columns")
600+
expand_repr = get_option("display.expand_frame_repr")
601601

602602
if max_columns > 0:
603603
if (len(self.index) <= max_rows and
@@ -642,7 +642,7 @@ def __bytes__(self):
642642
Invoked by bytes(df) in py3 only.
643643
Yields a bytestring in both py2/py3.
644644
"""
645-
encoding = com.get_option("print.encoding")
645+
encoding = com.get_option("display.encoding")
646646
return self.__unicode__().encode(encoding , 'replace')
647647

648648
def __unicode__(self):
@@ -659,7 +659,7 @@ def __unicode__(self):
659659
is_wide = self._need_wide_repr()
660660
line_width = None
661661
if is_wide:
662-
line_width = get_option('print.line_width')
662+
line_width = get_option('display.line_width')
663663
self.to_string(buf=buf, line_width=line_width)
664664

665665
value = buf.getvalue()
@@ -668,7 +668,7 @@ def __unicode__(self):
668668
return value
669669

670670
def _need_wide_repr(self):
671-
return (get_option("print.expand_frame_repr")
671+
return (get_option("display.expand_frame_repr")
672672
and com.in_interactive_session())
673673

674674
def __repr__(self):
@@ -687,7 +687,7 @@ def _repr_html_(self):
687687
if com.in_qtconsole():
688688
raise ValueError('Disable HTML output in QtConsole')
689689

690-
if get_option("print.notebook_repr_html"):
690+
if get_option("display.notebook_repr_html"):
691691
if self._need_info_repr_():
692692
return None
693693
else:
@@ -1597,7 +1597,7 @@ def info(self, verbose=True, buf=None, max_cols=None):
15971597

15981598
# hack
15991599
if max_cols is None:
1600-
max_cols = get_option('print.max_info_columns')
1600+
max_cols = get_option('display.max_info_columns')
16011601

16021602
if verbose and len(self.columns) <= max_cols:
16031603
lines.append('Data columns:')

pandas/core/index.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def __bytes__(self):
159159
Invoked by bytes(df) in py3 only.
160160
Yields a bytestring in both py2/py3.
161161
"""
162-
encoding = com.get_option("print.encoding")
162+
encoding = com.get_option("display.encoding")
163163
return self.__unicode__().encode(encoding , 'replace')
164164

165165
def __unicode__(self):
@@ -1380,7 +1380,7 @@ def __bytes__(self):
13801380
Invoked by bytes(df) in py3 only.
13811381
Yields a bytestring in both py2/py3.
13821382
"""
1383-
encoding = com.get_option("print.encoding")
1383+
encoding = com.get_option("display.encoding")
13841384
return self.__unicode__().encode(encoding , 'replace')
13851385

13861386
def __unicode__(self):
@@ -1586,7 +1586,7 @@ def format(self, space=2, sparsify=None, adjoin=True, names=False,
15861586
result_levels.append(level)
15871587

15881588
if sparsify is None:
1589-
sparsify = get_option("print.multi_sparse")
1589+
sparsify = get_option("display.multi_sparse")
15901590

15911591
if sparsify:
15921592
# little bit of a kludge job for #1217

pandas/core/panel.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ def __bytes__(self):
473473
Invoked by bytes(df) in py3 only.
474474
Yields a bytestring in both py2/py3.
475475
"""
476-
encoding = com.get_option("print.encoding")
476+
encoding = com.get_option("display.encoding")
477477
return self.__unicode__().encode(encoding , 'replace')
478478

479479
def __unicode__(self):
@@ -1556,7 +1556,7 @@ def _add_aggregate_operations(cls):
15561556
# doc strings substitors
15571557
_agg_doc = """
15581558
Wrapper method for %s
1559-
1559+
15601560
Parameters
15611561
----------
15621562
other : """ + "%s or %s" % (cls._constructor_sliced.__name__,cls.__name__) + """
@@ -1634,7 +1634,7 @@ def std(self, axis='major', skipna=True):
16341634
def skew(self, axis='major', skipna=True):
16351635
return self._reduce(nanops.nanskew, axis=axis, skipna=skipna)
16361636
cls.skew = skew
1637-
1637+
16381638
@Substitution(desc='product', outname='prod')
16391639
@Appender(_agg_doc)
16401640
def prod(self, axis='major', skipna=True):

0 commit comments

Comments
 (0)