diff --git a/README.rst b/README.rst
index 78e849275aaf2..8d000a9410e22 100644
--- a/README.rst
+++ b/README.rst
@@ -77,6 +77,8 @@ Optional dependencies
* Needed for parts of :mod:`pandas.stats`
* `pytz `__
* Needed for time zone support with ``DateRange``
+ * `openpyxl `__, `xlrd/xlwt `__
+ * Needed for Excel I/O
Installation from sources
=========================
diff --git a/doc/source/v0.10.0.txt b/doc/source/v0.10.0.txt
index 98eb4746c7d79..a93ff92321a9e 100644
--- a/doc/source/v0.10.0.txt
+++ b/doc/source/v0.10.0.txt
@@ -122,13 +122,17 @@ API changes
- ``reset_option`` - reset one or more options to their default value. Partial names are accepted.
- ``describe_option`` - print a description of one or more options. When called with no arguments. print all registered options.
- Note: ``set_printoptions`` is now deprecated (but functioning), the print options now live under "print_config.XYZ". For example:
+ Note: ``set_printoptions``/ ``reset_printoptions`` are now deprecated (but functioning), the print options now live under "print.XYZ". For example:
.. ipython:: python
import pandas as pd
- pd.get_option("print_config.max_rows")
+ pd.get_option("print.max_rows")
+
+
+ - to_string() methods now always return unicode strings (GH2224_).
+
See the `full release notes
`__ or issue tracker
@@ -138,3 +142,4 @@ on GitHub for a complete list.
.. _GH1996: https://github.com/pydata/pandas/issues/1996
.. _GH2316: https://github.com/pydata/pandas/issues/2316
.. _GH2097: https://github.com/pydata/pandas/issues/2097
+.. _GH2224: https://github.com/pydata/pandas/issues/2224
diff --git a/pandas/core/common.py b/pandas/core/common.py
index 2654f74888a21..b93cf05c7e768 100644
--- a/pandas/core/common.py
+++ b/pandas/core/common.py
@@ -1128,7 +1128,7 @@ def in_qtconsole():
# 2) If you need to send something to the console, use console_encode().
#
# console_encode() should (hopefully) choose the right encoding for you
-# based on the encoding set in option "print_config.encoding"
+# based on the encoding set in option "print.encoding"
#
# 3) if you need to write something out to file, use
# pprint_thing_encoded(encoding).
@@ -1187,10 +1187,10 @@ def pprint_thing(thing, _nest_lvl=0):
hasattr(thing,'next'):
return unicode(thing)
elif (isinstance(thing, dict) and
- _nest_lvl < get_option("print_config.pprint_nest_depth")):
+ _nest_lvl < get_option("print.pprint_nest_depth")):
result = _pprint_dict(thing, _nest_lvl)
elif _is_sequence(thing) and _nest_lvl < \
- get_option("print_config.pprint_nest_depth"):
+ get_option("print.pprint_nest_depth"):
result = _pprint_seq(thing, _nest_lvl)
else:
# when used internally in the package, everything
@@ -1222,8 +1222,8 @@ def console_encode(object):
this is the sanctioned way to prepare something for
sending *to the console*, it delegates to pprint_thing() to get
a unicode representation of the object relies on the global encoding
- set in print_config.encoding. Use this everywhere
+ set in print.encoding. Use this everywhere
where you output to the console.
"""
return pprint_thing_encoded(object,
- get_option("print_config.encoding"))
+ get_option("print.encoding"))
diff --git a/pandas/core/config.py b/pandas/core/config.py
index dff60162c42ce..ef0c540f99235 100644
--- a/pandas/core/config.py
+++ b/pandas/core/config.py
@@ -53,40 +53,25 @@
from collections import namedtuple
import warnings
-DeprecatedOption = namedtuple("DeprecatedOption", "key msg rkey removal_ver")
-RegisteredOption = namedtuple("RegisteredOption", "key defval doc validator")
+DeprecatedOption = namedtuple('DeprecatedOption', 'key msg rkey removal_ver')
+RegisteredOption = namedtuple('RegisteredOption', 'key defval doc validator')
+
+_deprecated_options = {} # holds deprecated option metdata
+_registered_options = {} # holds registered option metdata
+_global_config = {} # holds the current values for registered options
+_reserved_keys = ['all'] # keys which have a special meaning
-__deprecated_options = {} # holds deprecated option metdata
-__registered_options = {} # holds registered option metdata
-__global_config = {} # holds the current values for registered options
-__reserved_keys = ["all"] # keys which have a special meaning
##########################################
# User API
-
-def get_option(pat):
- """Retrieves the value of the specified option
-
- Parameters
- ----------
- pat - str/regexp which should match a single option.
-
- Returns
- -------
- result - the value of the option
-
- Raises
- ------
- KeyError if no such option exists
- """
-
+def _get_option(pat):
keys = _select_options(pat)
if len(keys) == 0:
_warn_if_deprecated(pat)
- raise KeyError("No such keys(s)")
+ raise KeyError('No such keys(s)')
if len(keys) > 1:
- raise KeyError("Pattern matched multiple keys")
+ raise KeyError('Pattern matched multiple keys')
key = keys[0]
_warn_if_deprecated(key)
@@ -99,27 +84,14 @@ def get_option(pat):
return root[k]
-def set_option(pat, value):
- """Sets the value of the specified option
+def _set_option(pat, value):
- Parameters
- ----------
- pat - str/regexp which should match a single option.
-
- Returns
- -------
- None
-
- Raises
- ------
- KeyError if no such option exists
- """
keys = _select_options(pat)
if len(keys) == 0:
_warn_if_deprecated(pat)
- raise KeyError("No such keys(s)")
+ raise KeyError('No such keys(s)')
if len(keys) > 1:
- raise KeyError("Pattern matched multiple keys")
+ raise KeyError('Pattern matched multiple keys')
key = keys[0]
_warn_if_deprecated(key)
@@ -134,73 +106,173 @@ def set_option(pat, value):
root[k] = value
-def describe_option(pat="",_print_desc=True):
- """ Prints the description for one or more registered options
+def _describe_option(pat='', _print_desc=True):
- Call with not arguments to get a listing for all registered options.
-
- Parameters
- ----------
- pat - str, a regexp pattern. All matching keys will have their
- description displayed.
-
- _print_desc - if True (default) the description(s) will be printed
- to stdout otherwise, the description(s) will be returned
- as a unicode string (for testing).
-
- Returns
- -------
- None by default, the description(s) as a unicode string if _print_desc
- is False
-
- """
keys = _select_options(pat)
if len(keys) == 0:
- raise KeyError("No such keys(s)")
+ raise KeyError('No such keys(s)')
- s=u""
- for k in keys: # filter by pat
+ s = u''
+ for k in keys: # filter by pat
s += _build_option_description(k)
if _print_desc:
- print(s)
+ print s
else:
- return(s)
+ return s
-def reset_option(pat):
- """Reset one or more options to their default value.
- pass "all" as argument to reset all options.
-
- Parameters
- ----------
- pat - str/regex if specified only options matching `prefix`* will be reset
-
- Returns
- -------
- None
+def _reset_option(pat):
- """
keys = _select_options(pat)
- if pat == u"":
- raise ValueError("You must provide a non-empty pattern")
+ if pat == u'':
+ raise ValueError('You must provide a non-empty pattern')
if len(keys) == 0:
- raise KeyError("No such keys(s)")
+ raise KeyError('No such keys(s)')
- if len(keys) > 1 and len(pat)<4 and pat != "all":
- raise ValueError("You must specify at least 4 characters "
- "when resetting multiple keys")
+ if len(keys) > 1 and len(pat) < 4 and pat != 'all':
+ raise ValueError('You must specify at least 4 characters when '
+ 'resetting multiple keys')
for k in keys:
- set_option(k, __registered_options[k].defval)
+ _set_option(k, _registered_options[k].defval)
+
+
+# For user convenience, we'd like to have the available options described
+# in the docstring. For dev convenience we'd like to generate the docstrings
+# dynamically instead of maintaining them by hand. To this, we use the
+# class below which wraps functions inside a callable, and converts
+# __doc__ into a propery function. The doctsrings below are templates
+# using the py2.6+ advanced formatting syntax to plug in a concise list
+# of options, and option descriptions.
+
+class CallableDyanmicDoc(object):
+
+ def __init__(self, func, doc_tmpl):
+ self.__doc_tmpl__ = doc_tmpl
+ self.__func__ = func
+
+ def __call__(self, *args, **kwds):
+ return self.__func__(*args, **kwds)
+
+ @property
+ def __doc__(self):
+ opts_desc = _describe_option('all', _print_desc=False)
+ opts_list = pp_options_list(_registered_options.keys())
+ return self.__doc_tmpl__.format(opts_desc=opts_desc,
+ opts_list=opts_list)
+
+_get_option_tmpl = """"get_option(pat) - Retrieves the value of the specified option
+
+Available options:
+{opts_list}
+
+Parameters
+----------
+pat - str/regexp which should match a single option.
+
+Note: partial matches are supported for convenience, but unless you use the
+full option name (e.g. x.y.z.option_name), your code may break in future
+versions if new options with similar names are introduced.
+
+Returns
+-------
+result - the value of the option
+
+Raises
+------
+KeyError if no such option exists
+
+{opts_desc}
+"""
+
+_set_option_tmpl="""set_option(pat,value) - Sets the value of the specified option
+
+Available options:
+{opts_list}
+
+Parameters
+----------
+pat - str/regexp which should match a single option.
+
+Note: partial matches are supported for convenience, but unless you use the
+full option name (e.g. x.y.z.option_name), your code may break in future
+versions if new options with similar names are introduced.
+
+value - new value of option.
+
+Returns
+-------
+None
+
+Raises
+------
+KeyError if no such option exists
+
+{opts_desc}
+"""
+
+_describe_option_tmpl="""describe_option(pat,_print_desc=False) Prints the description
+for one or more registered options.
+
+Call with not arguments to get a listing for all registered options.
+
+Available options:
+{opts_list}
+
+Parameters
+----------
+pat - str, a regexp pattern. All matching keys will have their
+ description displayed.
+
+_print_desc - if True (default) the description(s) will be printed
+ to stdout otherwise, the description(s) will be returned
+ as a unicode string (for testing).
+
+Returns
+-------
+None by default, the description(s) as a unicode string if _print_desc
+is False
+
+{opts_desc}
+"""
+
+_reset_option_tmpl="""reset_option(pat) - Reset one or more options to their default value.
+
+Pass "all" as argument to reset all options.
+
+Available options:
+{opts_list}
+
+Parameters
+----------
+pat - str/regex if specified only options matching `prefix`* will be reset
+
+Note: partial matches are supported for convenience, but unless you use the
+full option name (e.g. x.y.z.option_name), your code may break in future
+versions if new options with similar names are introduced.
+
+Returns
+-------
+None
+
+{opts_desc}
+"""
+
+# bind the functions with their docstrings into a Callable
+# and use that as the functions exposed in pd.api
+get_option = CallableDyanmicDoc(_get_option, _get_option_tmpl)
+set_option = CallableDyanmicDoc(_set_option, _set_option_tmpl)
+reset_option = CallableDyanmicDoc(_reset_option, _reset_option_tmpl)
+describe_option = CallableDyanmicDoc(_describe_option, _describe_option_tmpl)
+
######################################################
# Functions for use by pandas developers, in addition to User - api
-
-def register_option(key, defval, doc="", validator=None):
+def register_option(key, defval, doc='', validator=None):
"""Register an option in the package-wide pandas config object
Parameters
@@ -221,11 +293,11 @@ def register_option(key, defval, doc="", validator=None):
"""
- key=key.lower()
+ key = key.lower()
- if key in __registered_options:
+ if key in _registered_options:
raise KeyError("Option '%s' has already been registered" % key)
- if key in __reserved_keys:
+ if key in _reserved_keys:
raise KeyError("Option '%s' is a reserved key" % key)
# the default value should be legal
@@ -233,25 +305,25 @@ def register_option(key, defval, doc="", validator=None):
validator(defval)
# walk the nested dict, creating dicts as needed along the path
- path = key.split(".")
- cursor = __global_config
- for i,p in enumerate(path[:-1]):
- if not isinstance(cursor,dict):
- raise KeyError("Path prefix to option '%s' is already an option" %\
- ".".join(path[:i]))
+ path = key.split('.')
+ cursor = _global_config
+ for i, p in enumerate(path[:-1]):
+ if not isinstance(cursor, dict):
+ raise KeyError("Path prefix to option '%s' is already an option"
+ % '.'.join(path[:i]))
if not cursor.has_key(p):
cursor[p] = {}
cursor = cursor[p]
- if not isinstance(cursor,dict):
- raise KeyError("Path prefix to option '%s' is already an option" %\
- ".".join(path[:-1]))
+ if not isinstance(cursor, dict):
+ raise KeyError("Path prefix to option '%s' is already an option"
+ % '.'.join(path[:-1]))
- cursor[path[-1]] = defval # initialize
+ cursor[path[-1]] = defval # initialize
# save the option metadata
- __registered_options[key] = RegisteredOption(key=key, defval=defval,
- doc=doc, validator=validator)
+ _registered_options[key] = RegisteredOption(key=key, defval=defval,
+ doc=doc, validator=validator)
def deprecate_option(key, msg=None, rkey=None, removal_ver=None):
@@ -292,12 +364,15 @@ def deprecate_option(key, msg=None, rkey=None, removal_ver=None):
KeyError - if key has already been deprecated.
"""
- key=key.lower()
- if key in __deprecated_options:
- raise KeyError("Option '%s' has already been defined as deprecated." % key)
+ key = key.lower()
+
+ if key in _deprecated_options:
+ raise KeyError("Option '%s' has already been defined as deprecated."
+ % key)
+
+ _deprecated_options[key] = DeprecatedOption(key, msg, rkey, removal_ver)
- __deprecated_options[key] = DeprecatedOption(key, msg, rkey,removal_ver)
################################
# functions internal to the module
@@ -307,16 +382,17 @@ def _select_options(pat):
if pat=="all", returns all registered options
"""
- keys = sorted(__registered_options.keys())
- if pat == "all": # reserved key
+
+ keys = sorted(_registered_options.keys())
+ if pat == 'all': # reserved key
return keys
- return [k for k in keys if re.search(pat,k,re.I)]
+ return [k for k in keys if re.search(pat, k, re.I)]
def _get_root(key):
- path = key.split(".")
- cursor = __global_config
+ path = key.split('.')
+ cursor = _global_config
for p in path[:-1]:
cursor = cursor[p]
return cursor, path[-1]
@@ -326,7 +402,7 @@ def _is_deprecated(key):
""" Returns True if the given option has been deprecated """
key = key.lower()
- return __deprecated_options.has_key(key)
+ return _deprecated_options.has_key(key)
def _get_deprecated_option(key):
@@ -337,8 +413,9 @@ def _get_deprecated_option(key):
-------
DeprecatedOption (namedtuple) if key is deprecated, None otherwise
"""
+
try:
- d = __deprecated_options[key]
+ d = _deprecated_options[key]
except KeyError:
return None
else:
@@ -353,8 +430,9 @@ def _get_registered_option(key):
-------
RegisteredOption (namedtuple) if key is deprecated, None otherwise
"""
+
try:
- d = __registered_options[key]
+ d = _registered_options[key]
except KeyError:
return None
else:
@@ -366,6 +444,7 @@ def _translate_key(key):
if key id deprecated and a replacement key defined, will return the
replacement key, otherwise returns `key` as - is
"""
+
d = _get_deprecated_option(key)
if d:
return d.rkey or key
@@ -389,34 +468,65 @@ def _warn_if_deprecated(key):
else:
msg = "'%s' is deprecated" % key
if d.removal_ver:
- msg += " and will be removed in %s" % d.removal_ver
+ msg += ' and will be removed in %s' % d.removal_ver
if d.rkey:
- msg += (", please use '%s' instead." % (d.rkey))
+ msg += ", please use '%s' instead." % d.rkey
else:
- msg += (", please refrain from using it.")
+ msg += ', please refrain from using it.'
warnings.warn(msg, DeprecationWarning)
return True
return False
+
def _build_option_description(k):
""" Builds a formatted description of a registered option and prints it """
o = _get_registered_option(k)
d = _get_deprecated_option(k)
- s = u'%s: ' %k
+ s = u'%s: ' % k
if o.doc:
- s += "\n" +"\n ".join(o.doc.split("\n"))
+ s += '\n' + '\n '.join(o.doc.strip().split('\n'))
else:
- s += "No description available.\n"
+ s += 'No description available.\n'
if d:
- s += u"\n\t(Deprecated"
- s += u", use `%s` instead." % d.rkey if d.rkey else ""
- s += u")\n"
-
- s += "\n"
- return(s)
+ s += u'\n\t(Deprecated'
+ s += (u', use `%s` instead.' % d.rkey if d.rkey else '')
+ s += u')\n'
+
+ s += '\n'
+ return s
+
+
+def pp_options_list(keys, width=80, _print=False):
+ """ Builds a concise listing of available options, grouped by prefix """
+
+ from textwrap import wrap
+ from itertools import groupby
+
+ def pp(name, ks):
+ pfx = (name + '.[' if name else '')
+ ls = wrap(', '.join(ks), width, initial_indent=pfx,
+ subsequent_indent=' ' * len(pfx), break_long_words=False)
+ if ls and ls[-1] and name:
+ ls[-1] = ls[-1] + ']'
+ return ls
+
+ ls = []
+ singles = [x for x in sorted(keys) if x.find('.') < 0]
+ if singles:
+ ls += pp('', singles)
+ keys = [x for x in keys if x.find('.') >= 0]
+
+ for k, g in groupby(sorted(keys), lambda x: x[:x.rfind('.')]):
+ ks = [x[len(k) + 1:] for x in list(g)]
+ ls += pp(k, ks)
+ s = '\n'.join(ls)
+ if _print:
+ print s
+ else:
+ return s
##############
@@ -449,15 +559,18 @@ def config_prefix(prefix):
will register options "display.font.color", "display.font.size", set the
value of "display.font.size"... and so on.
"""
+
# Note: reset_option relies on set_option, and on key directly
# it does not fit in to this monkey-patching scheme
global register_option, get_option, set_option, reset_option
def wrap(func):
+
def inner(key, *args, **kwds):
- pkey="%s.%s" % (prefix, key)
+ pkey = '%s.%s' % (prefix, key)
return func(pkey, *args, **kwds)
+
return inner
_register_option = register_option
@@ -466,7 +579,7 @@ def inner(key, *args, **kwds):
set_option = wrap(set_option)
get_option = wrap(get_option)
register_option = wrap(register_option)
- yield
+ yield None
set_option = _set_option
get_option = _get_option
register_option = _register_option
@@ -474,6 +587,7 @@ def inner(key, *args, **kwds):
# These factories and methods are handy for use as the validator
# arg in register_option
+
def is_type_factory(_type):
"""
@@ -487,6 +601,7 @@ def is_type_factory(_type):
True if type(x) is equal to `_type`
"""
+
def inner(x):
if type(x) != _type:
raise ValueError("Value must have type '%s'" % str(_type))
@@ -507,12 +622,14 @@ def is_instance_factory(_type):
True if x is an instance of `_type`
"""
+
def inner(x):
if not isinstance(x, _type):
raise ValueError("Value must be an instance of '%s'" % str(_type))
return inner
+
# common type validators, for convenience
# usage: register_option(... , validator = is_int)
is_int = is_type_factory(int)
diff --git a/pandas/core/config_init.py b/pandas/core/config_init.py
index b0279a94983d9..a6739a1c450e9 100644
--- a/pandas/core/config_init.py
+++ b/pandas/core/config_init.py
@@ -1,5 +1,3 @@
-from __future__ import with_statement # support python 2.5
-
import pandas.core.config as cf
from pandas.core.config import is_int,is_bool,is_text,is_float
from pandas.core.format import detect_console_encoding
@@ -18,7 +16,7 @@
###########################################
-# options from the "print_config" namespace
+# options from the "print" namespace
pc_precision_doc="""
: int
@@ -79,7 +77,7 @@
these are generally strings meant to be displayed on the console.
"""
-with cf.config_prefix('print_config'):
+with cf.config_prefix('print'):
cf.register_option('precision', 7, pc_precision_doc, validator=is_int)
cf.register_option('digits', 7, validator=is_int)
cf.register_option('float_format', None)
diff --git a/pandas/core/format.py b/pandas/core/format.py
index 47aa072ffd644..f62e68a0f18a1 100644
--- a/pandas/core/format.py
+++ b/pandas/core/format.py
@@ -73,7 +73,7 @@ def __init__(self, series, buf=None, header=True, length=True,
self.header = header
if float_format is None:
- float_format = get_option("print_config.float_format")
+ float_format = get_option("print.float_format")
self.float_format = float_format
def _get_footer(self):
@@ -148,7 +148,7 @@ def _encode_diff_func():
if py3compat.PY3: # pragma: no cover
_encode_diff = lambda x: 0
else:
- encoding = get_option("print_config.encoding")
+ encoding = get_option("print.encoding")
def _encode_diff(x):
return len(x) - len(x.decode(encoding))
@@ -159,7 +159,7 @@ def _strlen_func():
if py3compat.PY3: # pragma: no cover
_strlen = len
else:
- encoding = get_option("print_config.encoding")
+ encoding = get_option("print.encoding")
def _strlen(x):
try:
return len(x.decode(encoding))
@@ -191,7 +191,7 @@ def __init__(self, frame, buf=None, columns=None, col_space=None,
self.show_index_names = index_names
if sparsify is None:
- sparsify = get_option("print_config.multi_sparse")
+ sparsify = get_option("print.multi_sparse")
self.sparsify = sparsify
@@ -203,7 +203,7 @@ def __init__(self, frame, buf=None, columns=None, col_space=None,
self.index = index
if justify is None:
- self.justify = get_option("print_config.colheader_justify")
+ self.justify = get_option("print.colheader_justify")
else:
self.justify = justify
@@ -930,13 +930,13 @@ def format_array(values, formatter, float_format=None, na_rep='NaN',
fmt_klass = GenericArrayFormatter
if space is None:
- space = get_option("print_config.column_space")
+ space = get_option("print.column_space")
if float_format is None:
- float_format = get_option("print_config.float_format")
+ float_format = get_option("print.float_format")
if digits is None:
- digits = get_option("print_config.precision")
+ digits = get_option("print.precision")
fmt_obj = fmt_klass(values, digits, na_rep=na_rep,
float_format=float_format,
@@ -964,9 +964,9 @@ def get_result(self):
def _format_strings(self):
if self.float_format is None:
- float_format = get_option("print_config.float_format")
+ float_format = get_option("print.float_format")
if float_format is None:
- fmt_str = '%% .%dg' % get_option("print_config.precision")
+ fmt_str = '%% .%dg' % get_option("print.precision")
float_format = lambda x: fmt_str % x
else:
float_format = self.float_format
@@ -1091,7 +1091,7 @@ def _make_fixed_width(strings, justify='right', minimum=None):
if minimum is not None:
max_len = max(minimum, max_len)
- conf_max = get_option("print_config.max_colwidth")
+ conf_max = get_option("print.max_colwidth")
if conf_max is not None and max_len > conf_max:
max_len = conf_max
@@ -1201,33 +1201,39 @@ def set_printoptions(precision=None, column_space=None, max_rows=None,
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("print_config.precision", precision)
+ set_option("print.precision", precision)
if column_space is not None:
- set_option("print_config.column_space", column_space)
+ set_option("print.column_space", column_space)
if max_rows is not None:
- set_option("print_config.max_rows", max_rows)
+ set_option("print.max_rows", max_rows)
if max_colwidth is not None:
- set_option("print_config.max_colwidth", max_colwidth)
+ set_option("print.max_colwidth", max_colwidth)
if max_columns is not None:
- set_option("print_config.max_columns", max_columns)
+ set_option("print.max_columns", max_columns)
if colheader_justify is not None:
- set_option("print_config.colheader_justify", colheader_justify)
+ set_option("print.colheader_justify", colheader_justify)
if notebook_repr_html is not None:
- set_option("print_config.notebook_repr_html", notebook_repr_html)
+ set_option("print.notebook_repr_html", notebook_repr_html)
if date_dayfirst is not None:
- set_option("print_config.date_dayfirst", date_dayfirst)
+ set_option("print.date_dayfirst", date_dayfirst)
if date_yearfirst is not None:
- set_option("print_config.date_yearfirst", date_yearfirst)
+ set_option("print.date_yearfirst", date_yearfirst)
if pprint_nest_depth is not None:
- set_option("print_config.pprint_nest_depth", pprint_nest_depth)
+ set_option("print.pprint_nest_depth", pprint_nest_depth)
if multi_sparse is not None:
- set_option("print_config.multi_sparse", multi_sparse)
+ set_option("print.multi_sparse", multi_sparse)
if encoding is not None:
- set_option("print_config.encoding", encoding)
+ set_option("print.encoding", encoding)
def reset_printoptions():
- reset_option("^print_config\.")
+ import warnings
+ warnings.warn("reset_printoptions is deprecated, use reset_option instead",
+ FutureWarning)
+ reset_option("^print\.")
def detect_console_encoding():
"""
@@ -1359,8 +1365,8 @@ def set_eng_float_format(precision=None, accuracy=3, use_eng_prefix=False):
"being renamed to 'accuracy'", FutureWarning)
accuracy = precision
- set_option("print_config.float_format", EngFormatter(accuracy, use_eng_prefix))
- set_option("print_config.column_space", max(12, accuracy + 9))
+ set_option("print.float_format", EngFormatter(accuracy, use_eng_prefix))
+ set_option("print.column_space", max(12, accuracy + 9))
def _put_lines(buf, lines):
if any(isinstance(x, unicode) for x in lines):
diff --git a/pandas/core/frame.py b/pandas/core/frame.py
index d9f2807937056..ba9431cdbafde 100644
--- a/pandas/core/frame.py
+++ b/pandas/core/frame.py
@@ -589,9 +589,9 @@ def _need_info_repr_(self):
terminal_width, terminal_height = 100, 100
else:
terminal_width, terminal_height = get_terminal_size()
- max_rows = (terminal_height if get_option("print_config.max_rows") == 0
- else get_option("print_config.max_rows"))
- max_columns = get_option("print_config.max_columns")
+ max_rows = (terminal_height if get_option("print.max_rows") == 0
+ else get_option("print.max_rows"))
+ max_columns = get_option("print.max_columns")
if max_columns > 0:
if len(self.index) <= max_rows and \
@@ -669,7 +669,7 @@ def _repr_html_(self):
if com.in_qtconsole():
raise ValueError('Disable HTML output in QtConsole')
- if get_option("print_config.notebook_repr_html"):
+ if get_option("print.notebook_repr_html"):
if self._need_info_repr_():
return None
else:
diff --git a/pandas/core/index.py b/pandas/core/index.py
index ba7817046fb3a..9f0992908a3a7 100644
--- a/pandas/core/index.py
+++ b/pandas/core/index.py
@@ -1583,7 +1583,7 @@ def format(self, space=2, sparsify=None, adjoin=True, names=False,
result_levels.append(level)
if sparsify is None:
- sparsify = get_option("print_config.multi_sparse")
+ sparsify = get_option("print.multi_sparse")
if sparsify:
# little bit of a kludge job for #1217
diff --git a/pandas/core/series.py b/pandas/core/series.py
index ae21014c2d9a7..cd257c849aad2 100644
--- a/pandas/core/series.py
+++ b/pandas/core/series.py
@@ -948,8 +948,8 @@ def __unicode__(self):
Invoked by unicode(df) in py2 only. Yields a Unicode String in both py2/py3.
"""
width, height = get_terminal_size()
- max_rows = (height if get_option("print_config.max_rows") == 0
- else get_option("print_config.max_rows"))
+ max_rows = (height if get_option("print.max_rows") == 0
+ else get_option("print.max_rows"))
if len(self.index) > (max_rows or 1000):
result = self._tidy_repr(min(30, max_rows - 4))
elif len(self.index) > 0:
diff --git a/pandas/tests/test_config.py b/pandas/tests/test_config.py
index 6b91fa1e78a1c..84459e1e9811a 100644
--- a/pandas/tests/test_config.py
+++ b/pandas/tests/test_config.py
@@ -13,19 +13,19 @@ def __init__(self,*args):
from copy import deepcopy
self.cf = pd.core.config
- self.gc=deepcopy(getattr(self.cf, '__global_config'))
- self.do=deepcopy(getattr(self.cf, '__deprecated_options'))
- self.ro=deepcopy(getattr(self.cf, '__registered_options'))
+ self.gc=deepcopy(getattr(self.cf, '_global_config'))
+ self.do=deepcopy(getattr(self.cf, '_deprecated_options'))
+ self.ro=deepcopy(getattr(self.cf, '_registered_options'))
def setUp(self):
- setattr(self.cf, '__global_config', {})
- setattr(self.cf, '__deprecated_options', {})
- setattr(self.cf, '__registered_options', {})
+ setattr(self.cf, '_global_config', {})
+ setattr(self.cf, '_deprecated_options', {})
+ setattr(self.cf, '_registered_options', {})
def tearDown(self):
- setattr(self.cf, '__global_config',self.gc)
- setattr(self.cf, '__deprecated_options', self.do)
- setattr(self.cf, '__registered_options', self.ro)
+ setattr(self.cf, '_global_config',self.gc)
+ setattr(self.cf, '_deprecated_options', self.do)
+ setattr(self.cf, '_registered_options', self.ro)
def test_api(self):
diff --git a/pandas/tests/test_format.py b/pandas/tests/test_format.py
index 1379615e9869b..c4e483fd57715 100644
--- a/pandas/tests/test_format.py
+++ b/pandas/tests/test_format.py
@@ -65,7 +65,7 @@ def test_repr_tuples(self):
def test_repr_truncation(self):
max_len = 20
- set_option("print_config.max_colwidth", max_len)
+ set_option("print.max_colwidth", max_len)
df = DataFrame({'A': np.random.randn(10),
'B': [tm.rands(np.random.randint(max_len - 1,
max_len + 1)) for i in range(10)]})
@@ -80,10 +80,10 @@ def test_repr_truncation(self):
else:
self.assert_('...' not in line)
- set_option("print_config.max_colwidth", 999999)
+ set_option("print.max_colwidth", 999999)
self.assert_('...' not in repr(df))
- set_option("print_config.max_colwidth", max_len + 2)
+ set_option("print.max_colwidth", max_len + 2)
self.assert_('...' not in repr(df))
def test_repr_should_return_str (self):
@@ -453,7 +453,7 @@ def test_to_string_float_formatting(self):
assert(df_s == expected)
fmt.reset_printoptions()
- self.assertEqual(get_option("print_config.precision"), 7)
+ self.assertEqual(get_option("print.precision"), 7)
df = DataFrame({'x': [1e9, 0.2512]})
df_s = df.to_string()
diff --git a/pandas/tseries/tools.py b/pandas/tseries/tools.py
index f6ce7229286e8..7010c3c6bbebf 100644
--- a/pandas/tseries/tools.py
+++ b/pandas/tseries/tools.py
@@ -222,9 +222,9 @@ def parse_time_string(arg, freq=None, dayfirst=None, yearfirst=None):
return mresult
if dayfirst is None:
- dayfirst = get_option("print_config.date_dayfirst")
+ dayfirst = get_option("print.date_dayfirst")
if yearfirst is None:
- yearfirst = get_option("print_config.date_yearfirst")
+ yearfirst = get_option("print.date_yearfirst")
try:
parsed = parse(arg, dayfirst=dayfirst, yearfirst=yearfirst)