+215
-94
lines changedFilter options
+215
-94
lines changed Original file line number Diff line number Diff line change
@@ -93,7 +93,7 @@ Accelerated operations
93
93
----------------------
94
94
95
95
pandas has support for accelerating certain types of binary numerical and boolean operations using
96
-
the ``numexpr`` library (starting in 0.11.0) and the ``bottleneck`` libraries.
96
+
the ``numexpr`` library and the ``bottleneck`` libraries.
97
97
98
98
These libraries are especially useful when dealing with large data sets, and provide large
99
99
speedups. ``numexpr`` uses smart chunking, caching, and multiple cores. ``bottleneck`` is
@@ -114,6 +114,15 @@ Here is a sample (using 100 column x 100,000 row ``DataFrames``):
114
114
You are highly encouraged to install both libraries. See the section
115
115
:ref:`Recommended Dependencies <install.recommended_dependencies>` for more installation info.
116
116
117
+
These are both enabled to be used by default, you can control this by setting the options:
118
+
119
+
.. versionadded:: 0.20.0
120
+
121
+
.. code-block:: python
122
+
123
+
pd.set_option('compute.use_bottleneck', False)
124
+
pd.set_option('compute.use_numexpr', False)
125
+
117
126
.. _basics.binop:
118
127
119
128
Flexible binary operations
Original file line number Diff line number Diff line change
@@ -425,6 +425,10 @@ mode.use_inf_as_null False True means treat None, NaN, -IN
425
425
INF as null (old way), False means
426
426
None and NaN are null, but INF, -INF
427
427
are not null (new way).
428
+
compute.use_bottleneck True Use the bottleneck library to accelerate
429
+
computation if it is installed
430
+
compute.use_numexpr True Use the numexpr library to accelerate
431
+
computation if it is installed
428
432
=================================== ============ ==================================
429
433
430
434
@@ -538,4 +542,4 @@ Only ``'display.max_rows'`` are serialized and published.
538
542
.. ipython:: python
539
543
:suppress:
540
544
541
-
pd.reset_option('display.html.table_schema')
545
+
pd.reset_option('display.html.table_schema')
Original file line number Diff line number Diff line change
@@ -521,6 +521,7 @@ Other Enhancements
521
521
- The ``display.show_dimensions`` option can now also be used to specify
522
522
whether the length of a ``Series`` should be shown in its repr (:issue:`7117`).
523
523
- ``parallel_coordinates()`` has gained a ``sort_labels`` keyword arg that sorts class labels and the colours assigned to them (:issue:`15908`)
524
+
- Options added to allow one to turn on/off using ``bottleneck`` and ``numexpr``, see :ref:`here <basics.accelerate>` (:issue:`16157`)
524
525
525
526
526
527
.. _ISO 8601 duration: https://en.wikipedia.org/wiki/ISO_8601#Durations
@@ -1217,7 +1218,7 @@ If indicated, a deprecation warning will be issued if you reference theses modul
1217
1218
1218
1219
"pandas.lib", "pandas._libs.lib", "X"
1219
1220
"pandas.tslib", "pandas._libs.tslib", "X"
1220
-
"pandas.computation", "pandas.core.computation", ""
1221
+
"pandas.computation", "pandas.core.computation", "X"
1221
1222
"pandas.msgpack", "pandas.io.msgpack", ""
1222
1223
"pandas.index", "pandas._libs.index", ""
1223
1224
"pandas.algos", "pandas._libs.algos", ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
1
+
import warnings
2
+
3
+
4
+
def set_use_numexpr(v=True):
5
+
warnings.warn("pandas.computation.expressions.set_use_numexpr is "
6
+
"deprecated and will be removed in a future version.\n"
7
+
"you can toggle usage of numexpr via "
8
+
"pandas.get_option('compute.use_numexpr')",
9
+
FutureWarning, stacklevel=2)
10
+
from pandas import set_option
11
+
set_option('compute.use_numexpr', v)
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
10
10
import numpy as np
11
11
from pandas.core.common import _values_from_object
12
12
from pandas.core.computation import _NUMEXPR_INSTALLED
13
+
from pandas.core.config import get_option
13
14
14
15
if _NUMEXPR_INSTALLED:
15
16
import numexpr as ne
@@ -156,7 +157,7 @@ def _where_numexpr(cond, a, b, raise_on_error=False):
156
157
157
158
158
159
# turn myself on
159
-
set_use_numexpr(True)
160
+
set_use_numexpr(get_option('compute.use_numexpr'))
160
161
161
162
162
163
def _has_bool_dtype(x):
Original file line number Diff line number Diff line change
@@ -15,8 +15,41 @@
15
15
from pandas.core.config import (is_int, is_bool, is_text, is_instance_factory,
16
16
is_one_of_factory, get_default_val,
17
17
is_callable)
18
-
from pandas.io.formats.format import detect_console_encoding
18
+
from pandas.io.formats.console import detect_console_encoding
19
19
20
+
# compute
21
+
22
+
use_bottleneck_doc = """
23
+
: bool
24
+
Use the bottleneck library to accelerate if it is installed,
25
+
the default is True
26
+
Valid values: False,True
27
+
"""
28
+
29
+
30
+
def use_bottleneck_cb(key):
31
+
from pandas.core import nanops
32
+
nanops.set_use_bottleneck(cf.get_option(key))
33
+
34
+
35
+
use_numexpr_doc = """
36
+
: bool
37
+
Use the numexpr library to accelerate computation if it is installed,
38
+
the default is True
39
+
Valid values: False,True
40
+
"""
41
+
42
+
43
+
def use_numexpr_cb(key):
44
+
from pandas.core.computation import expressions
45
+
expressions.set_use_numexpr(cf.get_option(key))
46
+
47
+
48
+
with cf.config_prefix('compute'):
49
+
cf.register_option('use_bottleneck', True, use_bottleneck_doc,
50
+
validator=is_bool, cb=use_bottleneck_cb)
51
+
cf.register_option('use_numexpr', True, use_numexpr_doc,
52
+
validator=is_bool, cb=use_numexpr_cb)
20
53
#
21
54
# options from the "display" namespace
22
55
Original file line number Diff line number Diff line change
@@ -91,6 +91,7 @@
91
91
import pandas.core.nanops as nanops
92
92
import pandas.core.ops as ops
93
93
import pandas.io.formats.format as fmt
94
+
import pandas.io.formats.console as console
94
95
from pandas.io.formats.printing import pprint_thing
95
96
import pandas.plotting._core as gfx
96
97
@@ -513,7 +514,7 @@ def _repr_fits_horizontal_(self, ignore_width=False):
513
514
GH3541, GH3573
514
515
"""
515
516
516
-
width, height = fmt.get_console_size()
517
+
width, height = console.get_console_size()
517
518
max_columns = get_option("display.max_columns")
518
519
nb_columns = len(self.columns)
519
520
@@ -577,7 +578,7 @@ def __unicode__(self):
577
578
max_cols = get_option("display.max_columns")
578
579
show_dimensions = get_option("display.show_dimensions")
579
580
if get_option("display.expand_frame_repr"):
580
-
width, _ = fmt.get_console_size()
581
+
width, _ = console.get_console_size()
581
582
else:
582
583
width = None
583
584
self.to_string(buf=buf, max_rows=max_rows, max_cols=max_cols,
Original file line number Diff line number Diff line change
@@ -837,7 +837,8 @@ def _format_data(self):
837
837
"""
838
838
Return the formatted data as a unicode string
839
839
"""
840
-
from pandas.io.formats.format import get_console_size, _get_adjustment
840
+
from pandas.io.formats.console import get_console_size
841
+
from pandas.io.formats.format import _get_adjustment
841
842
display_width, _ = get_console_size()
842
843
if display_width is None:
843
844
display_width = get_option('display.width') or 80
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
1
1
import itertools
2
2
import functools
3
-
import numpy as np
4
3
import operator
5
4
6
-
try:
7
-
import bottleneck as bn
8
-
_USE_BOTTLENECK = True
9
-
except ImportError: # pragma: no cover
10
-
_USE_BOTTLENECK = False
11
-
5
+
import numpy as np
12
6
from pandas import compat
13
7
from pandas._libs import tslib, algos, lib
14
8
from pandas.core.dtypes.common import (
@@ -23,9 +17,27 @@
23
17
is_int_or_datetime_dtype, is_any_int_dtype)
24
18
from pandas.core.dtypes.cast import _int64_max, maybe_upcast_putmask
25
19
from pandas.core.dtypes.missing import isnull, notnull
26
-
20
+
from pandas.core.config import get_option
27
21
from pandas.core.common import _values_from_object
28
22
23
+
try:
24
+
import bottleneck as bn
25
+
_BOTTLENECK_INSTALLED = True
26
+
except ImportError: # pragma: no cover
27
+
_BOTTLENECK_INSTALLED = False
28
+
29
+
_USE_BOTTLENECK = False
30
+
31
+
32
+
def set_use_bottleneck(v=True):
33
+
# set/unset to use bottleneck
34
+
global _USE_BOTTLENECK
35
+
if _BOTTLENECK_INSTALLED:
36
+
_USE_BOTTLENECK = v
37
+
38
+
39
+
set_use_bottleneck(get_option('compute.use_bottleneck'))
40
+
29
41
30
42
class disallow(object):
31
43
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4