""" This module is imported from the pandas package __init__.py file in order to ensure that the core.config options registered here will be available as soon as the user loads the package. if register_option is invoked inside specific modules, they will not be registered until that module is imported, which may or may not be a problem. If you need to make sure options are available even before a certain module is imported, register them here rather than in the module. """ import os from typing import Callable import warnings import pandas._config.config as cf from pandas._config.config import ( is_bool, is_callable, is_instance_factory, is_int, is_nonnegative_int, is_one_of_factory, is_str, is_text, ) from pandas.util._exceptions import find_stack_level # compute use_bottleneck_doc = """ : bool Use the bottleneck library to accelerate if it is installed, the default is True Valid values: False,True """ def use_bottleneck_cb(key): from pandas.core import nanops nanops.set_use_bottleneck(cf.get_option(key)) use_numexpr_doc = """ : bool Use the numexpr library to accelerate computation if it is installed, the default is True Valid values: False,True """ def use_numexpr_cb(key): from pandas.core.computation import expressions expressions.set_use_numexpr(cf.get_option(key)) use_numba_doc = """ : bool Use the numba engine option for select operations if it is installed, the default is False Valid values: False,True """ def use_numba_cb(key): from pandas.core.util import numba_ numba_.set_use_numba(cf.get_option(key)) with cf.config_prefix("compute"): cf.register_option( "use_bottleneck", True, use_bottleneck_doc, validator=is_bool, cb=use_bottleneck_cb, ) cf.register_option( "use_numexpr", True, use_numexpr_doc, validator=is_bool, cb=use_numexpr_cb ) cf.register_option( "use_numba", False, use_numba_doc, validator=is_bool, cb=use_numba_cb ) # # options from the "display" namespace pc_precision_doc = """ : int Floating point output precision in terms of number of places after the decimal, for regular formatting as well as scientific notation. Similar to ``precision`` in :meth:`numpy.set_printoptions`. """ pc_colspace_doc = """ : int Default space for DataFrame columns. """ pc_max_rows_doc = """ : int If max_rows is exceeded, switch to truncate view. Depending on `large_repr`, objects are either centrally truncated or printed as a summary view. 'None' value means unlimited. In case python/IPython is running in a terminal and `large_repr` equals 'truncate' this can be set to 0 and pandas will auto-detect the height of the terminal and print a truncated object which fits the screen height. The IPython notebook, IPython qtconsole, or IDLE do not run in a terminal and hence it is not possible to do correct auto-detection. """ pc_min_rows_doc = """ : int The numbers of rows to show in a truncated view (when `max_rows` is exceeded). Ignored when `max_rows` is set to None or 0. When set to None, follows the value of `max_rows`. """ pc_max_cols_doc = """ : int If max_cols is exceeded, switch to truncate view. Depending on `large_repr`, objects are either centrally truncated or printed as a summary view. 'None' value means unlimited. In case python/IPython is running in a terminal and `large_repr` equals 'truncate' this can be set to 0 and pandas will auto-detect the width of the terminal and print a truncated object which fits the screen width. The IPython notebook, IPython qtconsole, or IDLE do not run in a terminal and hence it is not possible to do correct auto-detection. """ pc_max_categories_doc = """ : int This sets the maximum number of categories pandas should output when printing out a `Categorical` or a Series of dtype "category". """ pc_max_info_cols_doc = """ : int max_info_columns is used in DataFrame.info method to decide if per column information will be printed. """ pc_nb_repr_h_doc = """ : boolean When True, IPython notebook will use html representation for pandas objects (if it is available). """ pc_pprint_nest_depth = """ : int Controls the number of nested levels to process when pretty-printing """ pc_multi_sparse_doc = """ : boolean "sparsify" MultiIndex display (don't display repeated elements in outer levels within groups) """ float_format_doc = """ : callable The callable should accept a floating point number and return a string with the desired format of the number. This is used in some places like SeriesFormatter. See formats.format.EngFormatter for an example. """ max_colwidth_doc = """ : int or None The maximum width in characters of a column in the repr of a pandas data structure. When the column overflows, a "..." placeholder is embedded in the output. A 'None' value means unlimited. """ colheader_justify_doc = """ : 'left'/'right' Controls the justification of column headers. used by DataFrameFormatter. """ pc_expand_repr_doc = """ : boolean Whether to print out the full DataFrame repr for wide DataFrames across multiple lines, `max_columns` is still respected, but the output will wrap-around across multiple "pages" if its width exceeds `display.width`. """ pc_show_dimensions_doc = """ : boolean or 'truncate' Whether to print out dimensions at the end of DataFrame repr. If 'truncate' is specified, only print out the dimensions if the frame is truncated (e.g. not display all rows and/or columns) """ pc_east_asian_width_doc = """ : boolean Whether to use the Unicode East Asian Width to calculate the display text width. Enabling this may affect to the performance (default: False) """ pc_ambiguous_as_wide_doc = """ : boolean Whether to handle Unicode characters belong to Ambiguous as Wide (width=2) (default: False) """ pc_latex_repr_doc = """ : boolean Whether to produce a latex DataFrame representation for jupyter environments that support it. (default: False) """ pc_table_schema_doc = """ : boolean Whether to publish a Table Schema representation for frontends that support it. (default: False) """ pc_html_border_doc = """ : int A ``border=value`` attribute is inserted in the ``
) elements that will be rendered before trimming will occur over columns, rows or both if needed. """ styler_max_rows = """ : int, optional The maximum number of rows that will be rendered. May still be reduced to satsify ``max_elements``, which takes precedence. """ styler_max_columns = """ : int, optional The maximum number of columns that will be rendered. May still be reduced to satsify ``max_elements``, which takes precedence. """ styler_precision = """ : int The precision for floats and complex numbers. """ styler_decimal = """ : str The character representation for the decimal separator for floats and complex. """ styler_thousands = """ : str, optional The character representation for thousands separator for floats, int and complex. """ styler_na_rep = """ : str, optional The string representation for values identified as missing. """ styler_escape = """ : str, optional Whether to escape certain characters according to the given context; html or latex. """ styler_formatter = """ : str, callable, dict, optional A formatter object to be used as default within ``Styler.format``. """ styler_multirow_align = """ : {"c", "t", "b"} The specifier for vertical alignment of sparsified LaTeX multirows. """ styler_multicol_align = r""" : {"r", "c", "l", "naive-l", "naive-r"} The specifier for horizontal alignment of sparsified LaTeX multicolumns. Pipe decorators can also be added to non-naive values to draw vertical rules, e.g. "\|r" will draw a rule on the left side of right aligned merged cells. """ styler_hrules = """ : bool Whether to add horizontal rules on top and bottom and below the headers. """ styler_environment = """ : str The environment to replace ``\\begin{table}``. If "longtable" is used results in a specific longtable environment format. """ styler_encoding = """ : str The encoding used for output HTML and LaTeX files. """ styler_mathjax = """ : bool If False will render special CSS classes to table attributes that indicate Mathjax will not be used in Jupyter Notebook. """ with cf.config_prefix("styler"): cf.register_option("sparse.index", True, styler_sparse_index_doc, validator=is_bool) cf.register_option( "sparse.columns", True, styler_sparse_columns_doc, validator=is_bool ) cf.register_option( "render.repr", "html", styler_render_repr, validator=is_one_of_factory(["html", "latex"]), ) cf.register_option( "render.max_elements", 2**18, styler_max_elements, validator=is_nonnegative_int, ) cf.register_option( "render.max_rows", None, styler_max_rows, validator=is_nonnegative_int, ) cf.register_option( "render.max_columns", None, styler_max_columns, validator=is_nonnegative_int, ) cf.register_option("render.encoding", "utf-8", styler_encoding, validator=is_str) cf.register_option("format.decimal", ".", styler_decimal, validator=is_str) cf.register_option( "format.precision", 6, styler_precision, validator=is_nonnegative_int ) cf.register_option( "format.thousands", None, styler_thousands, validator=is_instance_factory([type(None), str]), ) cf.register_option( "format.na_rep", None, styler_na_rep, validator=is_instance_factory([type(None), str]), ) cf.register_option( "format.escape", None, styler_escape, validator=is_one_of_factory([None, "html", "latex"]), ) cf.register_option( "format.formatter", None, styler_formatter, validator=is_instance_factory([type(None), dict, Callable, str]), ) cf.register_option("html.mathjax", True, styler_mathjax, validator=is_bool) cf.register_option( "latex.multirow_align", "c", styler_multirow_align, validator=is_one_of_factory(["c", "t", "b", "naive"]), ) val_mca = ["r", "|r|", "|r", "r|", "c", "|c|", "|c", "c|", "l", "|l|", "|l", "l|"] val_mca += ["naive-l", "naive-r"] cf.register_option( "latex.multicol_align", "r", styler_multicol_align, validator=is_one_of_factory(val_mca), ) cf.register_option("latex.hrules", False, styler_hrules, validator=is_bool) cf.register_option( "latex.environment", None, styler_environment, validator=is_instance_factory([type(None), str]), ) |