当前位置: 首页>>代码示例>>Python>>正文


Python config.get_option方法代码示例

本文整理汇总了Python中pandas.core.config.get_option方法的典型用法代码示例。如果您正苦于以下问题:Python config.get_option方法的具体用法?Python config.get_option怎么用?Python config.get_option使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pandas.core.config的用法示例。


在下文中一共展示了config.get_option方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: set_engine_and_path

# 需要导入模块: from pandas.core import config [as 别名]
# 或者: from pandas.core.config import get_option [as 别名]
def set_engine_and_path(self, request, merge_cells, engine, ext):
        """Fixture to set engine and open file for use in each test case

        Rather than requiring `engine=...` to be provided explicitly as an
        argument in each test, this fixture sets a global option to dictate
        which engine should be used to write Excel files. After executing
        the test it rolls back said change to the global option.

        It also uses a context manager to open a temporary excel file for
        the function to write to, accessible via `self.path`

        Notes
        -----
        This fixture will run as part of each test method defined in the
        class and any subclasses, on account of the `autouse=True`
        argument
        """
        option_name = 'io.excel.{ext}.writer'.format(ext=ext.strip('.'))
        prev_engine = get_option(option_name)
        set_option(option_name, engine)
        with ensure_clean(ext) as path:
            self.path = path
            yield
        set_option(option_name, prev_engine)  # Roll back option change 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:26,代码来源:test_excel.py

示例2: _repr_categories

# 需要导入模块: from pandas.core import config [as 别名]
# 或者: from pandas.core.config import get_option [as 别名]
def _repr_categories(self):
        """
        return the base repr for the categories
        """
        max_categories = (10 if get_option("display.max_categories") == 0 else
                          get_option("display.max_categories"))
        from pandas.io.formats import format as fmt
        if len(self.categories) > max_categories:
            num = max_categories // 2
            head = fmt.format_array(self.categories[:num], None)
            tail = fmt.format_array(self.categories[-num:], None)
            category_strs = head + ["..."] + tail
        else:
            category_strs = fmt.format_array(self.categories, None)

        # Strip all leading spaces, which format_array adds for columns...
        category_strs = [x.strip() for x in category_strs]
        return category_strs 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:20,代码来源:categorical.py

示例3: _use_inf_as_na

# 需要导入模块: from pandas.core import config [as 别名]
# 或者: from pandas.core.config import get_option [as 别名]
def _use_inf_as_na(key):
    """Option change callback for na/inf behaviour
    Choose which replacement for numpy.isnan / -numpy.isfinite is used.

    Parameters
    ----------
    flag: bool
        True means treat None, NaN, INF, -INF as null (old way),
        False means None and NaN are null, but INF, -INF are not null
        (new way).

    Notes
    -----
    This approach to setting global module values is discussed and
    approved here:

    * http://stackoverflow.com/questions/4859217/
      programmatically-creating-variables-in-python/4859312#4859312
    """
    from pandas.core.config import get_option
    flag = get_option(key)
    if flag:
        globals()['_isna'] = _isna_old
    else:
        globals()['_isna'] = _isna_new 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:27,代码来源:missing.py

示例4: __unicode__

# 需要导入模块: from pandas.core import config [as 别名]
# 或者: from pandas.core.config import get_option [as 别名]
def __unicode__(self):
        """
        Return a string representation for a particular DataFrame.

        Invoked by unicode(df) in py2 only. Yields a Unicode String in both
        py2/py3.
        """
        buf = StringIO(u(""))
        width, height = get_terminal_size()
        max_rows = (height if get_option("display.max_rows") == 0 else
                    get_option("display.max_rows"))
        show_dimensions = get_option("display.show_dimensions")

        self.to_string(buf=buf, name=self.name, dtype=self.dtype,
                       max_rows=max_rows, length=show_dimensions)
        result = buf.getvalue()

        return result 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:20,代码来源:series.py

示例5: format_object_attrs

# 需要导入模块: from pandas.core import config [as 别名]
# 或者: from pandas.core.config import get_option [as 别名]
def format_object_attrs(obj):
    """
    Return a list of tuples of the (attr, formatted_value)
    for common attrs, including dtype, name, length

    Parameters
    ----------
    obj : object
        must be iterable

    Returns
    -------
    list

    """
    attrs = []
    if hasattr(obj, 'dtype'):
        attrs.append(('dtype', "'{}'".format(obj.dtype)))
    if getattr(obj, 'name', None) is not None:
        attrs.append(('name', default_pprint(obj.name)))
    max_seq_items = get_option('display.max_seq_items') or len(obj)
    if len(obj) > max_seq_items:
        attrs.append(('length', len(obj)))
    return attrs 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:26,代码来源:printing.py

示例6: __init__

# 需要导入模块: from pandas.core import config [as 别名]
# 或者: from pandas.core.config import get_option [as 别名]
def __init__(self, series, buf=None, length=True, header=True, index=True,
                 na_rep='NaN', name=False, float_format=None, dtype=True,
                 max_rows=None):
        self.series = series
        self.buf = buf if buf is not None else StringIO()
        self.name = name
        self.na_rep = na_rep
        self.header = header
        self.length = length
        self.index = index
        self.max_rows = max_rows

        if float_format is None:
            float_format = get_option("display.float_format")
        self.float_format = float_format
        self.dtype = dtype
        self.adj = _get_adjustment()

        self._chk_truncate() 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:21,代码来源:format.py

示例7: __new__

# 需要导入模块: from pandas.core import config [as 别名]
# 或者: from pandas.core.config import get_option [as 别名]
def __new__(cls, path, engine=None, **kwargs):
        # only switch class if generic(ExcelWriter)

        if issubclass(cls, ExcelWriter):
            if engine is None or (isinstance(engine, string_types) and
                                  engine == 'auto'):
                if isinstance(path, string_types):
                    ext = os.path.splitext(path)[-1][1:]
                else:
                    ext = 'xlsx'

                try:
                    engine = config.get_option('io.excel.{ext}.writer'
                                               .format(ext=ext))
                    if engine == 'auto':
                        engine = _get_default_writer(ext)
                except KeyError:
                    error = ValueError("No engine for filetype: '{ext}'"
                                       .format(ext=ext))
                    raise error
            cls = get_writer(engine)

        return object.__new__(cls)

    # declare external properties you can count on 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:27,代码来源:excel.py

示例8: _repr_categories

# 需要导入模块: from pandas.core import config [as 别名]
# 或者: from pandas.core.config import get_option [as 别名]
def _repr_categories(self):
        """ return the base repr for the categories """
        max_categories = (10 if get_option("display.max_categories") == 0 else
                          get_option("display.max_categories"))
        from pandas.io.formats import format as fmt
        if len(self.categories) > max_categories:
            num = max_categories // 2
            head = fmt.format_array(self.categories[:num], None)
            tail = fmt.format_array(self.categories[-num:], None)
            category_strs = head + ["..."] + tail
        else:
            category_strs = fmt.format_array(self.categories, None)

        # Strip all leading spaces, which format_array adds for columns...
        category_strs = [x.strip() for x in category_strs]
        return category_strs 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:18,代码来源:categorical.py

示例9: _format_attrs

# 需要导入模块: from pandas.core import config [as 别名]
# 或者: from pandas.core.config import get_option [as 别名]
def _format_attrs(self):
        """
        Return a list of tuples of the (attr,formatted_value)
        """
        max_categories = (10 if get_option("display.max_categories") == 0 else
                          get_option("display.max_categories"))
        attrs = [
            ('categories',
             ibase.default_pprint(self.categories,
                                  max_seq_items=max_categories)),
            ('ordered', self.ordered)]
        if self.name is not None:
            attrs.append(('name', ibase.default_pprint(self.name)))
        attrs.append(('dtype', "'%s'" % self.dtype.name))
        max_seq_items = get_option('display.max_seq_items') or len(self)
        if len(self) > max_seq_items:
            attrs.append(('length', len(self)))
        return attrs 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:20,代码来源:category.py

示例10: __init__

# 需要导入模块: from pandas.core import config [as 别名]
# 或者: from pandas.core.config import get_option [as 别名]
def __init__(self, formatter, classes=None, max_rows=None, max_cols=None,
                 notebook=False, border=None, table_id=None):
        self.fmt = formatter
        self.classes = classes

        self.frame = self.fmt.frame
        self.columns = self.fmt.tr_frame.columns
        self.elements = []
        self.bold_rows = self.fmt.kwds.get('bold_rows', False)
        self.escape = self.fmt.kwds.get('escape', True)

        self.max_rows = max_rows or len(self.fmt.frame)
        self.max_cols = max_cols or len(self.fmt.columns)
        self.show_dimensions = self.fmt.show_dimensions
        self.is_truncated = (self.max_rows < len(self.fmt.frame) or
                             self.max_cols < len(self.fmt.columns))
        self.notebook = notebook
        if border is None:
            border = get_option('display.html.border')
        self.border = border
        self.table_id = table_id 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:23,代码来源:html.py

示例11: mpl_style_cb

# 需要导入模块: from pandas.core import config [as 别名]
# 或者: from pandas.core.config import get_option [as 别名]
def mpl_style_cb(key):
    import sys
    from pandas.tools.plotting import mpl_stylesheet
    global style_backup

    val = cf.get_option(key)

    if 'matplotlib' not in sys.modules.keys():
        if not(val):  # starting up, we get reset to None
            return val
        raise Exception("matplotlib has not been imported. aborting")

    import matplotlib.pyplot as plt

    if val == 'default':
        style_backup = dict([(k, plt.rcParams[k]) for k in mpl_stylesheet])
        plt.rcParams.update(mpl_stylesheet)
    elif not val:
        if style_backup:
            plt.rcParams.update(style_backup)

    return val 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:24,代码来源:config_init.py

示例12: __repr__

# 需要导入模块: from pandas.core import config [as 别名]
# 或者: from pandas.core.config import get_option [as 别名]
def __repr__(self):
        encoding = get_option('display.encoding')
        attrs = [('levels', default_pprint(self.levels)),
                 ('labels', default_pprint(self.labels))]
        if not all(name is None for name in self.names):
            attrs.append(('names', default_pprint(self.names)))
        if self.sortorder is not None:
            attrs.append(('sortorder', default_pprint(self.sortorder)))

        space = ' ' * (len(self.__class__.__name__) + 1)
        prepr = (u(",\n%s") % space).join([u("%s=%s") % (k, v)
                                          for k, v in attrs])
        res = u("%s(%s)") % (self.__class__.__name__, prepr)

        if not compat.PY3:
            # needs to be str in Python 2
            res = res.encode(encoding)
        return res 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:20,代码来源:index.py

示例13: _use_inf_as_null

# 需要导入模块: from pandas.core import config [as 别名]
# 或者: from pandas.core.config import get_option [as 别名]
def _use_inf_as_null(key):
    """Option change callback for null/inf behaviour
    Choose which replacement for numpy.isnan / -numpy.isfinite is used.

    Parameters
    ----------
    flag: bool
        True means treat None, NaN, INF, -INF as null (old way),
        False means None and NaN are null, but INF, -INF are not null
        (new way).

    Notes
    -----
    This approach to setting global module values is discussed and
    approved here:

    * http://stackoverflow.com/questions/4859217/
      programmatically-creating-variables-in-python/4859312#4859312
    """
    flag = get_option(key)
    if flag:
        globals()['_isnull'] = _isnull_old
    else:
        globals()['_isnull'] = _isnull_new 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:26,代码来源:common.py

示例14: _pprint_dict

# 需要导入模块: from pandas.core import config [as 别名]
# 或者: from pandas.core.config import get_option [as 别名]
def _pprint_dict(seq, _nest_lvl=0, **kwds):
    """
    internal. pprinter for iterables. you should probably use pprint_thing()
    rather then calling this directly.
    """
    fmt = u("{%s}")
    pairs = []

    pfmt = u("%s: %s")

    nitems = get_option("max_seq_items") or len(seq)

    for k, v in list(seq.items())[:nitems]:
        pairs.append(pfmt % (pprint_thing(k, _nest_lvl + 1, **kwds),
                             pprint_thing(v, _nest_lvl + 1, **kwds)))

    if nitems < len(seq):
        return fmt % (", ".join(pairs) + ", ...")
    else:
        return fmt % ", ".join(pairs) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:22,代码来源:common.py

示例15: test_repr_binary_type

# 需要导入模块: from pandas.core import config [as 别名]
# 或者: from pandas.core.config import get_option [as 别名]
def test_repr_binary_type():
    import string
    letters = string.ascii_letters
    btype = compat.binary_type
    try:
        raw = btype(letters, encoding=cf.get_option('display.encoding'))
    except TypeError:
        raw = btype(letters)
    b = compat.text_type(compat.bytes_to_str(raw))
    res = printing.pprint_thing(b, quote_strings=True)
    assert res == repr(b)
    res = printing.pprint_thing(b, quote_strings=False)
    assert res == b 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:15,代码来源:test_printing.py


注:本文中的pandas.core.config.get_option方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。