forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
62 lines (54 loc) · 1.59 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"""
pandas._config is considered explicitly upstream of everything else in pandas,
should have no intra-pandas dependencies.
importing `dates` and `display` ensures that keys needed by _libs
are initialized.
"""
__all__ = [
"config",
"detect_console_encoding",
"get_option",
"set_option",
"reset_option",
"describe_option",
"option_context",
"options",
"using_copy_on_write",
]
from pandas._config import config
from pandas._config import dates # pyright: ignore # noqa:F401
from pandas._config.config import (
_global_config,
describe_option,
get_option,
option_context,
options,
reset_option,
set_option,
)
from pandas._config.display import detect_console_encoding
def using_copy_on_write() -> bool:
"""
Determine if copy-on-write mode is enabled.
Copy-on-write is a memory-saving technique that avoids copying data
until it is actually modified, which can be particularly useful when
working with large datasets.
Returns
-------
bool
'True' if copy-on-write mode is enabled and the data manager
is set to "block", otherwise 'False'.
Example
-------
>>> pd.set_option("mode.copy_on_write", True)
>>> using_copy_on_write()
True
>>> pd.set_option("mode.copy_on_write", False)
>>> using_copy_on_write()
False
"""
_mode_options = _global_config["mode"]
return _mode_options["copy_on_write"] and _mode_options["data_manager"] == "block"
def using_nullable_dtypes() -> bool:
_mode_options = _global_config["mode"]
return _mode_options["nullable_dtypes"]