Beispiel #1
0
    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))


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)
#
# options from the "display" namespace

pc_precision_doc = """
: int
    Floating point output precision (number of significant digits). This is
    only a suggestion
Beispiel #2
0
: 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))


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)
#
# options from the "display" namespace

pc_precision_doc = """
: int
    Floating point output precision (number of significant digits). This is
    only a suggestion
"""
Beispiel #3
0
    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
Beispiel #4
0
"""
config for datetime formatting
"""
from __future__ import annotations

from pandas._config import config as cf

pc_date_dayfirst_doc = """
: boolean
    When True, prints and parses dates with the day first, eg 20/01/2005
"""

pc_date_yearfirst_doc = """
: boolean
    When True, prints and parses dates with the year first, eg 2005/01/20
"""

with cf.config_prefix("display"):
    # Needed upstream of `_libs` because these are used in tslibs.parsing
    cf.register_option("date_dayfirst",
                       False,
                       pc_date_dayfirst_doc,
                       validator=cf.is_bool)
    cf.register_option("date_yearfirst",
                       False,
                       pc_date_yearfirst_doc,
                       validator=cf.is_bool)
Beispiel #5
0
"""
config for datetime formatting
"""
from pandas._config import config as cf

pc_date_dayfirst_doc = """
: boolean
    When True, prints and parses dates with the day first, eg 20/01/2005
"""

pc_date_yearfirst_doc = """
: boolean
    When True, prints and parses dates with the year first, eg 2005/01/20
"""

with cf.config_prefix('display'):
    # Needed upstream of `_libs` because these are used in tslibs.parsing
    cf.register_option('date_dayfirst', False, pc_date_dayfirst_doc,
                       validator=cf.is_bool)
    cf.register_option('date_yearfirst', False, pc_date_yearfirst_doc,
                       validator=cf.is_bool)
Beispiel #6
0
        except locale.Error:
            # can be raised by locale.setlocale(), which is
            #  called by getpreferredencoding
            #  (on some systems, see stdlib locale docs)
            pass

    # when all else fails. this will usually be "ascii"
    if not encoding or "ascii" in encoding.lower():
        encoding = sys.getdefaultencoding()

    # GH#3360, save the reported defencoding at import time
    # MPL backends may change it. Make available for debugging.
    if not _initial_defencoding:
        _initial_defencoding = sys.getdefaultencoding()

    return encoding


pc_encoding_doc = """
: str/unicode
    Defaults to the detected encoding of the console.
    Specifies the encoding to be used for strings returned by to_string,
    these are generally strings meant to be displayed on the console.
"""

with cf.config_prefix("display"):
    cf.register_option("encoding",
                       detect_console_encoding(),
                       pc_encoding_doc,
                       validator=cf.is_text)
Beispiel #7
0
    # try again for something better
    if not encoding or 'ascii' in encoding.lower():
        try:
            encoding = locale.getpreferredencoding()
        except Exception:
            pass

    # when all else fails. this will usually be "ascii"
    if not encoding or 'ascii' in encoding.lower():
        encoding = sys.getdefaultencoding()

    # GH#3360, save the reported defencoding at import time
    # MPL backends may change it. Make available for debugging.
    if not _initial_defencoding:
        _initial_defencoding = sys.getdefaultencoding()

    return encoding


pc_encoding_doc = """
: str/unicode
    Defaults to the detected encoding of the console.
    Specifies the encoding to be used for strings returned by to_string,
    these are generally strings meant to be displayed on the console.
"""

with cf.config_prefix('display'):
    cf.register_option('encoding', detect_console_encoding(), pc_encoding_doc,
                       validator=cf.is_text)
Beispiel #8
0
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))


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)
#
# options from the "display" namespace

pc_precision_doc = """
: int
    Floating point output precision (number of significant digits). This is
    only a suggestion
"""

pc_colspace_doc = """
: int
    Default space for DataFrame columns.
"""
Beispiel #9
0
 def register(self, key, default_value, doc=""):
     if key in registered_options:
         del registered_options[key]
     # Lift from https://github.com/pandas-dev/pandas/blob/aa1089f5568927bd660a6b5d824b20d456703929/pandas/_config/config.py#L423
     register_option(key, default_value, doc)
Beispiel #10
0
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
"""
This is a temporary mechanism to wrap around pandas option machinery.
We'll need a permanent solution later on for two main reasons:
1. Users can accidentally clear options via pandas api
2. We need better type handling to help bridge jvm-python communication (GH134)
"""
import os
import tempfile

import pandas as pd
from pandas._config.config import (
    get_option,
    register_option,
    reset_option,
    set_option,
)

options = pd.options

CONF_RIKAI_CACHEURI = "rikai.cache_uri"
DEFAULT_RIKAI_CACHEURI = os.path.join(tempfile.gettempdir(), "rikai")
os.makedirs(DEFAULT_RIKAI_CACHEURI, exist_ok=True)
register_option(CONF_RIKAI_CACHEURI, DEFAULT_RIKAI_CACHEURI)

CONF_PARQUET_BLOCK_SIZE = "parquet.block.size"
DEFAULT_ROW_GROUP_SIZE_BYTES = 32 * 1024 * 1024
register_option(CONF_PARQUET_BLOCK_SIZE, DEFAULT_ROW_GROUP_SIZE_BYTES)