Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- lib/python3.12/site-packages/pandas/_config/__init__.py +57 -0
- lib/python3.12/site-packages/pandas/_config/__pycache__/__init__.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/pandas/_config/__pycache__/config.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/pandas/_config/__pycache__/dates.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/pandas/_config/__pycache__/display.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/pandas/_config/__pycache__/localization.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/pandas/_config/config.py +948 -0
- lib/python3.12/site-packages/pandas/_config/dates.py +25 -0
- lib/python3.12/site-packages/pandas/_config/display.py +62 -0
- lib/python3.12/site-packages/pandas/_config/localization.py +172 -0
- lib/python3.12/site-packages/pandas/_libs/__pycache__/__init__.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/pandas/_libs/tslibs/__init__.py +87 -0
- lib/python3.12/site-packages/pandas/_libs/tslibs/__pycache__/__init__.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/pandas/_libs/tslibs/base.cpython-312-x86_64-linux-gnu.so +0 -0
- lib/python3.12/site-packages/pandas/_libs/tslibs/ccalendar.pyi +12 -0
- lib/python3.12/site-packages/pandas/_libs/tslibs/conversion.pyi +14 -0
- lib/python3.12/site-packages/pandas/_libs/tslibs/dtypes.pyi +83 -0
- lib/python3.12/site-packages/pandas/_libs/tslibs/fields.pyi +62 -0
- lib/python3.12/site-packages/pandas/_libs/tslibs/nattype.pyi +141 -0
- lib/python3.12/site-packages/pandas/_libs/tslibs/np_datetime.pyi +27 -0
- lib/python3.12/site-packages/pandas/_libs/tslibs/offsets.pyi +287 -0
- lib/python3.12/site-packages/pandas/_libs/tslibs/parsing.pyi +33 -0
- lib/python3.12/site-packages/pandas/_libs/tslibs/period.pyi +135 -0
- lib/python3.12/site-packages/pandas/_libs/tslibs/strptime.pyi +14 -0
- lib/python3.12/site-packages/pandas/_libs/tslibs/timedeltas.pyi +174 -0
- lib/python3.12/site-packages/pandas/_libs/tslibs/timestamps.pyi +241 -0
- lib/python3.12/site-packages/pandas/_libs/tslibs/timezones.pyi +21 -0
- lib/python3.12/site-packages/pandas/_libs/tslibs/tzconversion.pyi +21 -0
- lib/python3.12/site-packages/pandas/_libs/tslibs/vectorized.pyi +43 -0
- lib/python3.12/site-packages/pandas/_libs/window/__init__.py +0 -0
- lib/python3.12/site-packages/pandas/_libs/window/__pycache__/__init__.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/pandas/_libs/window/aggregations.pyi +127 -0
- lib/python3.12/site-packages/pandas/_libs/window/indexers.pyi +12 -0
- lib/python3.12/site-packages/pandas/api/__init__.py +16 -0
- lib/python3.12/site-packages/pandas/api/__pycache__/__init__.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/pandas/api/extensions/__init__.py +33 -0
- lib/python3.12/site-packages/pandas/api/extensions/__pycache__/__init__.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/pandas/api/indexers/__init__.py +17 -0
- lib/python3.12/site-packages/pandas/api/indexers/__pycache__/__init__.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/pandas/api/interchange/__init__.py +8 -0
- lib/python3.12/site-packages/pandas/api/interchange/__pycache__/__init__.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/pandas/api/types/__init__.py +23 -0
- lib/python3.12/site-packages/pandas/api/types/__pycache__/__init__.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/pandas/api/typing/__init__.py +55 -0
- lib/python3.12/site-packages/pandas/api/typing/__pycache__/__init__.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/pandas/compat/__init__.py +199 -0
- lib/python3.12/site-packages/pandas/compat/__pycache__/__init__.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/pandas/compat/__pycache__/_constants.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/pandas/compat/__pycache__/_optional.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/pandas/compat/__pycache__/compressors.cpython-312.pyc +0 -0
lib/python3.12/site-packages/pandas/_config/__init__.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pandas._config is considered explicitly upstream of everything else in pandas,
|
| 3 |
+
should have no intra-pandas dependencies.
|
| 4 |
+
|
| 5 |
+
importing `dates` and `display` ensures that keys needed by _libs
|
| 6 |
+
are initialized.
|
| 7 |
+
"""
|
| 8 |
+
__all__ = [
|
| 9 |
+
"config",
|
| 10 |
+
"detect_console_encoding",
|
| 11 |
+
"get_option",
|
| 12 |
+
"set_option",
|
| 13 |
+
"reset_option",
|
| 14 |
+
"describe_option",
|
| 15 |
+
"option_context",
|
| 16 |
+
"options",
|
| 17 |
+
"using_copy_on_write",
|
| 18 |
+
"warn_copy_on_write",
|
| 19 |
+
]
|
| 20 |
+
from pandas._config import config
|
| 21 |
+
from pandas._config import dates # pyright: ignore[reportUnusedImport] # noqa: F401
|
| 22 |
+
from pandas._config.config import (
|
| 23 |
+
_global_config,
|
| 24 |
+
describe_option,
|
| 25 |
+
get_option,
|
| 26 |
+
option_context,
|
| 27 |
+
options,
|
| 28 |
+
reset_option,
|
| 29 |
+
set_option,
|
| 30 |
+
)
|
| 31 |
+
from pandas._config.display import detect_console_encoding
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def using_copy_on_write() -> bool:
|
| 35 |
+
_mode_options = _global_config["mode"]
|
| 36 |
+
return (
|
| 37 |
+
_mode_options["copy_on_write"] is True
|
| 38 |
+
and _mode_options["data_manager"] == "block"
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def warn_copy_on_write() -> bool:
|
| 43 |
+
_mode_options = _global_config["mode"]
|
| 44 |
+
return (
|
| 45 |
+
_mode_options["copy_on_write"] == "warn"
|
| 46 |
+
and _mode_options["data_manager"] == "block"
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def using_nullable_dtypes() -> bool:
|
| 51 |
+
_mode_options = _global_config["mode"]
|
| 52 |
+
return _mode_options["nullable_dtypes"]
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def using_pyarrow_string_dtype() -> bool:
|
| 56 |
+
_mode_options = _global_config["future"]
|
| 57 |
+
return _mode_options["infer_string"]
|
lib/python3.12/site-packages/pandas/_config/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (1.79 kB). View file
|
|
|
lib/python3.12/site-packages/pandas/_config/__pycache__/config.cpython-312.pyc
ADDED
|
Binary file (32.4 kB). View file
|
|
|
lib/python3.12/site-packages/pandas/_config/__pycache__/dates.cpython-312.pyc
ADDED
|
Binary file (990 Bytes). View file
|
|
|
lib/python3.12/site-packages/pandas/_config/__pycache__/display.cpython-312.pyc
ADDED
|
Binary file (2.06 kB). View file
|
|
|
lib/python3.12/site-packages/pandas/_config/__pycache__/localization.cpython-312.pyc
ADDED
|
Binary file (6.09 kB). View file
|
|
|
lib/python3.12/site-packages/pandas/_config/config.py
ADDED
|
@@ -0,0 +1,948 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
The config module holds package-wide configurables and provides
|
| 3 |
+
a uniform API for working with them.
|
| 4 |
+
|
| 5 |
+
Overview
|
| 6 |
+
========
|
| 7 |
+
|
| 8 |
+
This module supports the following requirements:
|
| 9 |
+
- options are referenced using keys in dot.notation, e.g. "x.y.option - z".
|
| 10 |
+
- keys are case-insensitive.
|
| 11 |
+
- functions should accept partial/regex keys, when unambiguous.
|
| 12 |
+
- options can be registered by modules at import time.
|
| 13 |
+
- options can be registered at init-time (via core.config_init)
|
| 14 |
+
- options have a default value, and (optionally) a description and
|
| 15 |
+
validation function associated with them.
|
| 16 |
+
- options can be deprecated, in which case referencing them
|
| 17 |
+
should produce a warning.
|
| 18 |
+
- deprecated options can optionally be rerouted to a replacement
|
| 19 |
+
so that accessing a deprecated option reroutes to a differently
|
| 20 |
+
named option.
|
| 21 |
+
- options can be reset to their default value.
|
| 22 |
+
- all option can be reset to their default value at once.
|
| 23 |
+
- all options in a certain sub - namespace can be reset at once.
|
| 24 |
+
- the user can set / get / reset or ask for the description of an option.
|
| 25 |
+
- a developer can register and mark an option as deprecated.
|
| 26 |
+
- you can register a callback to be invoked when the option value
|
| 27 |
+
is set or reset. Changing the stored value is considered misuse, but
|
| 28 |
+
is not verboten.
|
| 29 |
+
|
| 30 |
+
Implementation
|
| 31 |
+
==============
|
| 32 |
+
|
| 33 |
+
- Data is stored using nested dictionaries, and should be accessed
|
| 34 |
+
through the provided API.
|
| 35 |
+
|
| 36 |
+
- "Registered options" and "Deprecated options" have metadata associated
|
| 37 |
+
with them, which are stored in auxiliary dictionaries keyed on the
|
| 38 |
+
fully-qualified key, e.g. "x.y.z.option".
|
| 39 |
+
|
| 40 |
+
- the config_init module is imported by the package's __init__.py file.
|
| 41 |
+
placing any register_option() calls there will ensure those options
|
| 42 |
+
are available as soon as pandas is loaded. If you use register_option
|
| 43 |
+
in a module, it will only be available after that module is imported,
|
| 44 |
+
which you should be aware of.
|
| 45 |
+
|
| 46 |
+
- `config_prefix` is a context_manager (for use with the `with` keyword)
|
| 47 |
+
which can save developers some typing, see the docstring.
|
| 48 |
+
|
| 49 |
+
"""
|
| 50 |
+
|
| 51 |
+
from __future__ import annotations
|
| 52 |
+
|
| 53 |
+
from contextlib import (
|
| 54 |
+
ContextDecorator,
|
| 55 |
+
contextmanager,
|
| 56 |
+
)
|
| 57 |
+
import re
|
| 58 |
+
from typing import (
|
| 59 |
+
TYPE_CHECKING,
|
| 60 |
+
Any,
|
| 61 |
+
Callable,
|
| 62 |
+
Generic,
|
| 63 |
+
NamedTuple,
|
| 64 |
+
cast,
|
| 65 |
+
)
|
| 66 |
+
import warnings
|
| 67 |
+
|
| 68 |
+
from pandas._typing import (
|
| 69 |
+
F,
|
| 70 |
+
T,
|
| 71 |
+
)
|
| 72 |
+
from pandas.util._exceptions import find_stack_level
|
| 73 |
+
|
| 74 |
+
if TYPE_CHECKING:
|
| 75 |
+
from collections.abc import (
|
| 76 |
+
Generator,
|
| 77 |
+
Iterable,
|
| 78 |
+
)
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
class DeprecatedOption(NamedTuple):
|
| 82 |
+
key: str
|
| 83 |
+
msg: str | None
|
| 84 |
+
rkey: str | None
|
| 85 |
+
removal_ver: str | None
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
class RegisteredOption(NamedTuple):
|
| 89 |
+
key: str
|
| 90 |
+
defval: object
|
| 91 |
+
doc: str
|
| 92 |
+
validator: Callable[[object], Any] | None
|
| 93 |
+
cb: Callable[[str], Any] | None
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
# holds deprecated option metadata
|
| 97 |
+
_deprecated_options: dict[str, DeprecatedOption] = {}
|
| 98 |
+
|
| 99 |
+
# holds registered option metadata
|
| 100 |
+
_registered_options: dict[str, RegisteredOption] = {}
|
| 101 |
+
|
| 102 |
+
# holds the current values for registered options
|
| 103 |
+
_global_config: dict[str, Any] = {}
|
| 104 |
+
|
| 105 |
+
# keys which have a special meaning
|
| 106 |
+
_reserved_keys: list[str] = ["all"]
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
class OptionError(AttributeError, KeyError):
|
| 110 |
+
"""
|
| 111 |
+
Exception raised for pandas.options.
|
| 112 |
+
|
| 113 |
+
Backwards compatible with KeyError checks.
|
| 114 |
+
|
| 115 |
+
Examples
|
| 116 |
+
--------
|
| 117 |
+
>>> pd.options.context
|
| 118 |
+
Traceback (most recent call last):
|
| 119 |
+
OptionError: No such option
|
| 120 |
+
"""
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
#
|
| 124 |
+
# User API
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
def _get_single_key(pat: str, silent: bool) -> str:
|
| 128 |
+
keys = _select_options(pat)
|
| 129 |
+
if len(keys) == 0:
|
| 130 |
+
if not silent:
|
| 131 |
+
_warn_if_deprecated(pat)
|
| 132 |
+
raise OptionError(f"No such keys(s): {repr(pat)}")
|
| 133 |
+
if len(keys) > 1:
|
| 134 |
+
raise OptionError("Pattern matched multiple keys")
|
| 135 |
+
key = keys[0]
|
| 136 |
+
|
| 137 |
+
if not silent:
|
| 138 |
+
_warn_if_deprecated(key)
|
| 139 |
+
|
| 140 |
+
key = _translate_key(key)
|
| 141 |
+
|
| 142 |
+
return key
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
def _get_option(pat: str, silent: bool = False) -> Any:
|
| 146 |
+
key = _get_single_key(pat, silent)
|
| 147 |
+
|
| 148 |
+
# walk the nested dict
|
| 149 |
+
root, k = _get_root(key)
|
| 150 |
+
return root[k]
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
def _set_option(*args, **kwargs) -> None:
|
| 154 |
+
# must at least 1 arg deal with constraints later
|
| 155 |
+
nargs = len(args)
|
| 156 |
+
if not nargs or nargs % 2 != 0:
|
| 157 |
+
raise ValueError("Must provide an even number of non-keyword arguments")
|
| 158 |
+
|
| 159 |
+
# default to false
|
| 160 |
+
silent = kwargs.pop("silent", False)
|
| 161 |
+
|
| 162 |
+
if kwargs:
|
| 163 |
+
kwarg = next(iter(kwargs.keys()))
|
| 164 |
+
raise TypeError(f'_set_option() got an unexpected keyword argument "{kwarg}"')
|
| 165 |
+
|
| 166 |
+
for k, v in zip(args[::2], args[1::2]):
|
| 167 |
+
key = _get_single_key(k, silent)
|
| 168 |
+
|
| 169 |
+
o = _get_registered_option(key)
|
| 170 |
+
if o and o.validator:
|
| 171 |
+
o.validator(v)
|
| 172 |
+
|
| 173 |
+
# walk the nested dict
|
| 174 |
+
root, k_root = _get_root(key)
|
| 175 |
+
root[k_root] = v
|
| 176 |
+
|
| 177 |
+
if o.cb:
|
| 178 |
+
if silent:
|
| 179 |
+
with warnings.catch_warnings(record=True):
|
| 180 |
+
o.cb(key)
|
| 181 |
+
else:
|
| 182 |
+
o.cb(key)
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
def _describe_option(pat: str = "", _print_desc: bool = True) -> str | None:
|
| 186 |
+
keys = _select_options(pat)
|
| 187 |
+
if len(keys) == 0:
|
| 188 |
+
raise OptionError("No such keys(s)")
|
| 189 |
+
|
| 190 |
+
s = "\n".join([_build_option_description(k) for k in keys])
|
| 191 |
+
|
| 192 |
+
if _print_desc:
|
| 193 |
+
print(s)
|
| 194 |
+
return None
|
| 195 |
+
return s
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
def _reset_option(pat: str, silent: bool = False) -> None:
|
| 199 |
+
keys = _select_options(pat)
|
| 200 |
+
|
| 201 |
+
if len(keys) == 0:
|
| 202 |
+
raise OptionError("No such keys(s)")
|
| 203 |
+
|
| 204 |
+
if len(keys) > 1 and len(pat) < 4 and pat != "all":
|
| 205 |
+
raise ValueError(
|
| 206 |
+
"You must specify at least 4 characters when "
|
| 207 |
+
"resetting multiple keys, use the special keyword "
|
| 208 |
+
'"all" to reset all the options to their default value'
|
| 209 |
+
)
|
| 210 |
+
|
| 211 |
+
for k in keys:
|
| 212 |
+
_set_option(k, _registered_options[k].defval, silent=silent)
|
| 213 |
+
|
| 214 |
+
|
| 215 |
+
def get_default_val(pat: str):
|
| 216 |
+
key = _get_single_key(pat, silent=True)
|
| 217 |
+
return _get_registered_option(key).defval
|
| 218 |
+
|
| 219 |
+
|
| 220 |
+
class DictWrapper:
|
| 221 |
+
"""provide attribute-style access to a nested dict"""
|
| 222 |
+
|
| 223 |
+
d: dict[str, Any]
|
| 224 |
+
|
| 225 |
+
def __init__(self, d: dict[str, Any], prefix: str = "") -> None:
|
| 226 |
+
object.__setattr__(self, "d", d)
|
| 227 |
+
object.__setattr__(self, "prefix", prefix)
|
| 228 |
+
|
| 229 |
+
def __setattr__(self, key: str, val: Any) -> None:
|
| 230 |
+
prefix = object.__getattribute__(self, "prefix")
|
| 231 |
+
if prefix:
|
| 232 |
+
prefix += "."
|
| 233 |
+
prefix += key
|
| 234 |
+
# you can't set new keys
|
| 235 |
+
# can you can't overwrite subtrees
|
| 236 |
+
if key in self.d and not isinstance(self.d[key], dict):
|
| 237 |
+
_set_option(prefix, val)
|
| 238 |
+
else:
|
| 239 |
+
raise OptionError("You can only set the value of existing options")
|
| 240 |
+
|
| 241 |
+
def __getattr__(self, key: str):
|
| 242 |
+
prefix = object.__getattribute__(self, "prefix")
|
| 243 |
+
if prefix:
|
| 244 |
+
prefix += "."
|
| 245 |
+
prefix += key
|
| 246 |
+
try:
|
| 247 |
+
v = object.__getattribute__(self, "d")[key]
|
| 248 |
+
except KeyError as err:
|
| 249 |
+
raise OptionError("No such option") from err
|
| 250 |
+
if isinstance(v, dict):
|
| 251 |
+
return DictWrapper(v, prefix)
|
| 252 |
+
else:
|
| 253 |
+
return _get_option(prefix)
|
| 254 |
+
|
| 255 |
+
def __dir__(self) -> list[str]:
|
| 256 |
+
return list(self.d.keys())
|
| 257 |
+
|
| 258 |
+
|
| 259 |
+
# For user convenience, we'd like to have the available options described
|
| 260 |
+
# in the docstring. For dev convenience we'd like to generate the docstrings
|
| 261 |
+
# dynamically instead of maintaining them by hand. To this, we use the
|
| 262 |
+
# class below which wraps functions inside a callable, and converts
|
| 263 |
+
# __doc__ into a property function. The doctsrings below are templates
|
| 264 |
+
# using the py2.6+ advanced formatting syntax to plug in a concise list
|
| 265 |
+
# of options, and option descriptions.
|
| 266 |
+
|
| 267 |
+
|
| 268 |
+
class CallableDynamicDoc(Generic[T]):
|
| 269 |
+
def __init__(self, func: Callable[..., T], doc_tmpl: str) -> None:
|
| 270 |
+
self.__doc_tmpl__ = doc_tmpl
|
| 271 |
+
self.__func__ = func
|
| 272 |
+
|
| 273 |
+
def __call__(self, *args, **kwds) -> T:
|
| 274 |
+
return self.__func__(*args, **kwds)
|
| 275 |
+
|
| 276 |
+
# error: Signature of "__doc__" incompatible with supertype "object"
|
| 277 |
+
@property
|
| 278 |
+
def __doc__(self) -> str: # type: ignore[override]
|
| 279 |
+
opts_desc = _describe_option("all", _print_desc=False)
|
| 280 |
+
opts_list = pp_options_list(list(_registered_options.keys()))
|
| 281 |
+
return self.__doc_tmpl__.format(opts_desc=opts_desc, opts_list=opts_list)
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
_get_option_tmpl = """
|
| 285 |
+
get_option(pat)
|
| 286 |
+
|
| 287 |
+
Retrieves the value of the specified option.
|
| 288 |
+
|
| 289 |
+
Available options:
|
| 290 |
+
|
| 291 |
+
{opts_list}
|
| 292 |
+
|
| 293 |
+
Parameters
|
| 294 |
+
----------
|
| 295 |
+
pat : str
|
| 296 |
+
Regexp which should match a single option.
|
| 297 |
+
Note: partial matches are supported for convenience, but unless you use the
|
| 298 |
+
full option name (e.g. x.y.z.option_name), your code may break in future
|
| 299 |
+
versions if new options with similar names are introduced.
|
| 300 |
+
|
| 301 |
+
Returns
|
| 302 |
+
-------
|
| 303 |
+
result : the value of the option
|
| 304 |
+
|
| 305 |
+
Raises
|
| 306 |
+
------
|
| 307 |
+
OptionError : if no such option exists
|
| 308 |
+
|
| 309 |
+
Notes
|
| 310 |
+
-----
|
| 311 |
+
Please reference the :ref:`User Guide <options>` for more information.
|
| 312 |
+
|
| 313 |
+
The available options with its descriptions:
|
| 314 |
+
|
| 315 |
+
{opts_desc}
|
| 316 |
+
|
| 317 |
+
Examples
|
| 318 |
+
--------
|
| 319 |
+
>>> pd.get_option('display.max_columns') # doctest: +SKIP
|
| 320 |
+
4
|
| 321 |
+
"""
|
| 322 |
+
|
| 323 |
+
_set_option_tmpl = """
|
| 324 |
+
set_option(pat, value)
|
| 325 |
+
|
| 326 |
+
Sets the value of the specified option.
|
| 327 |
+
|
| 328 |
+
Available options:
|
| 329 |
+
|
| 330 |
+
{opts_list}
|
| 331 |
+
|
| 332 |
+
Parameters
|
| 333 |
+
----------
|
| 334 |
+
pat : str
|
| 335 |
+
Regexp which should match a single option.
|
| 336 |
+
Note: partial matches are supported for convenience, but unless you use the
|
| 337 |
+
full option name (e.g. x.y.z.option_name), your code may break in future
|
| 338 |
+
versions if new options with similar names are introduced.
|
| 339 |
+
value : object
|
| 340 |
+
New value of option.
|
| 341 |
+
|
| 342 |
+
Returns
|
| 343 |
+
-------
|
| 344 |
+
None
|
| 345 |
+
|
| 346 |
+
Raises
|
| 347 |
+
------
|
| 348 |
+
OptionError if no such option exists
|
| 349 |
+
|
| 350 |
+
Notes
|
| 351 |
+
-----
|
| 352 |
+
Please reference the :ref:`User Guide <options>` for more information.
|
| 353 |
+
|
| 354 |
+
The available options with its descriptions:
|
| 355 |
+
|
| 356 |
+
{opts_desc}
|
| 357 |
+
|
| 358 |
+
Examples
|
| 359 |
+
--------
|
| 360 |
+
>>> pd.set_option('display.max_columns', 4)
|
| 361 |
+
>>> df = pd.DataFrame([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]])
|
| 362 |
+
>>> df
|
| 363 |
+
0 1 ... 3 4
|
| 364 |
+
0 1 2 ... 4 5
|
| 365 |
+
1 6 7 ... 9 10
|
| 366 |
+
[2 rows x 5 columns]
|
| 367 |
+
>>> pd.reset_option('display.max_columns')
|
| 368 |
+
"""
|
| 369 |
+
|
| 370 |
+
_describe_option_tmpl = """
|
| 371 |
+
describe_option(pat, _print_desc=False)
|
| 372 |
+
|
| 373 |
+
Prints the description for one or more registered options.
|
| 374 |
+
|
| 375 |
+
Call with no arguments to get a listing for all registered options.
|
| 376 |
+
|
| 377 |
+
Available options:
|
| 378 |
+
|
| 379 |
+
{opts_list}
|
| 380 |
+
|
| 381 |
+
Parameters
|
| 382 |
+
----------
|
| 383 |
+
pat : str
|
| 384 |
+
Regexp pattern. All matching keys will have their description displayed.
|
| 385 |
+
_print_desc : bool, default True
|
| 386 |
+
If True (default) the description(s) will be printed to stdout.
|
| 387 |
+
Otherwise, the description(s) will be returned as a unicode string
|
| 388 |
+
(for testing).
|
| 389 |
+
|
| 390 |
+
Returns
|
| 391 |
+
-------
|
| 392 |
+
None by default, the description(s) as a unicode string if _print_desc
|
| 393 |
+
is False
|
| 394 |
+
|
| 395 |
+
Notes
|
| 396 |
+
-----
|
| 397 |
+
Please reference the :ref:`User Guide <options>` for more information.
|
| 398 |
+
|
| 399 |
+
The available options with its descriptions:
|
| 400 |
+
|
| 401 |
+
{opts_desc}
|
| 402 |
+
|
| 403 |
+
Examples
|
| 404 |
+
--------
|
| 405 |
+
>>> pd.describe_option('display.max_columns') # doctest: +SKIP
|
| 406 |
+
display.max_columns : int
|
| 407 |
+
If max_cols is exceeded, switch to truncate view...
|
| 408 |
+
"""
|
| 409 |
+
|
| 410 |
+
_reset_option_tmpl = """
|
| 411 |
+
reset_option(pat)
|
| 412 |
+
|
| 413 |
+
Reset one or more options to their default value.
|
| 414 |
+
|
| 415 |
+
Pass "all" as argument to reset all options.
|
| 416 |
+
|
| 417 |
+
Available options:
|
| 418 |
+
|
| 419 |
+
{opts_list}
|
| 420 |
+
|
| 421 |
+
Parameters
|
| 422 |
+
----------
|
| 423 |
+
pat : str/regex
|
| 424 |
+
If specified only options matching `prefix*` will be reset.
|
| 425 |
+
Note: partial matches are supported for convenience, but unless you
|
| 426 |
+
use the full option name (e.g. x.y.z.option_name), your code may break
|
| 427 |
+
in future versions if new options with similar names are introduced.
|
| 428 |
+
|
| 429 |
+
Returns
|
| 430 |
+
-------
|
| 431 |
+
None
|
| 432 |
+
|
| 433 |
+
Notes
|
| 434 |
+
-----
|
| 435 |
+
Please reference the :ref:`User Guide <options>` for more information.
|
| 436 |
+
|
| 437 |
+
The available options with its descriptions:
|
| 438 |
+
|
| 439 |
+
{opts_desc}
|
| 440 |
+
|
| 441 |
+
Examples
|
| 442 |
+
--------
|
| 443 |
+
>>> pd.reset_option('display.max_columns') # doctest: +SKIP
|
| 444 |
+
"""
|
| 445 |
+
|
| 446 |
+
# bind the functions with their docstrings into a Callable
|
| 447 |
+
# and use that as the functions exposed in pd.api
|
| 448 |
+
get_option = CallableDynamicDoc(_get_option, _get_option_tmpl)
|
| 449 |
+
set_option = CallableDynamicDoc(_set_option, _set_option_tmpl)
|
| 450 |
+
reset_option = CallableDynamicDoc(_reset_option, _reset_option_tmpl)
|
| 451 |
+
describe_option = CallableDynamicDoc(_describe_option, _describe_option_tmpl)
|
| 452 |
+
options = DictWrapper(_global_config)
|
| 453 |
+
|
| 454 |
+
#
|
| 455 |
+
# Functions for use by pandas developers, in addition to User - api
|
| 456 |
+
|
| 457 |
+
|
| 458 |
+
class option_context(ContextDecorator):
|
| 459 |
+
"""
|
| 460 |
+
Context manager to temporarily set options in the `with` statement context.
|
| 461 |
+
|
| 462 |
+
You need to invoke as ``option_context(pat, val, [(pat, val), ...])``.
|
| 463 |
+
|
| 464 |
+
Examples
|
| 465 |
+
--------
|
| 466 |
+
>>> from pandas import option_context
|
| 467 |
+
>>> with option_context('display.max_rows', 10, 'display.max_columns', 5):
|
| 468 |
+
... pass
|
| 469 |
+
"""
|
| 470 |
+
|
| 471 |
+
def __init__(self, *args) -> None:
|
| 472 |
+
if len(args) % 2 != 0 or len(args) < 2:
|
| 473 |
+
raise ValueError(
|
| 474 |
+
"Need to invoke as option_context(pat, val, [(pat, val), ...])."
|
| 475 |
+
)
|
| 476 |
+
|
| 477 |
+
self.ops = list(zip(args[::2], args[1::2]))
|
| 478 |
+
|
| 479 |
+
def __enter__(self) -> None:
|
| 480 |
+
self.undo = [(pat, _get_option(pat)) for pat, val in self.ops]
|
| 481 |
+
|
| 482 |
+
for pat, val in self.ops:
|
| 483 |
+
_set_option(pat, val, silent=True)
|
| 484 |
+
|
| 485 |
+
def __exit__(self, *args) -> None:
|
| 486 |
+
if self.undo:
|
| 487 |
+
for pat, val in self.undo:
|
| 488 |
+
_set_option(pat, val, silent=True)
|
| 489 |
+
|
| 490 |
+
|
| 491 |
+
def register_option(
|
| 492 |
+
key: str,
|
| 493 |
+
defval: object,
|
| 494 |
+
doc: str = "",
|
| 495 |
+
validator: Callable[[object], Any] | None = None,
|
| 496 |
+
cb: Callable[[str], Any] | None = None,
|
| 497 |
+
) -> None:
|
| 498 |
+
"""
|
| 499 |
+
Register an option in the package-wide pandas config object
|
| 500 |
+
|
| 501 |
+
Parameters
|
| 502 |
+
----------
|
| 503 |
+
key : str
|
| 504 |
+
Fully-qualified key, e.g. "x.y.option - z".
|
| 505 |
+
defval : object
|
| 506 |
+
Default value of the option.
|
| 507 |
+
doc : str
|
| 508 |
+
Description of the option.
|
| 509 |
+
validator : Callable, optional
|
| 510 |
+
Function of a single argument, should raise `ValueError` if
|
| 511 |
+
called with a value which is not a legal value for the option.
|
| 512 |
+
cb
|
| 513 |
+
a function of a single argument "key", which is called
|
| 514 |
+
immediately after an option value is set/reset. key is
|
| 515 |
+
the full name of the option.
|
| 516 |
+
|
| 517 |
+
Raises
|
| 518 |
+
------
|
| 519 |
+
ValueError if `validator` is specified and `defval` is not a valid value.
|
| 520 |
+
|
| 521 |
+
"""
|
| 522 |
+
import keyword
|
| 523 |
+
import tokenize
|
| 524 |
+
|
| 525 |
+
key = key.lower()
|
| 526 |
+
|
| 527 |
+
if key in _registered_options:
|
| 528 |
+
raise OptionError(f"Option '{key}' has already been registered")
|
| 529 |
+
if key in _reserved_keys:
|
| 530 |
+
raise OptionError(f"Option '{key}' is a reserved key")
|
| 531 |
+
|
| 532 |
+
# the default value should be legal
|
| 533 |
+
if validator:
|
| 534 |
+
validator(defval)
|
| 535 |
+
|
| 536 |
+
# walk the nested dict, creating dicts as needed along the path
|
| 537 |
+
path = key.split(".")
|
| 538 |
+
|
| 539 |
+
for k in path:
|
| 540 |
+
if not re.match("^" + tokenize.Name + "$", k):
|
| 541 |
+
raise ValueError(f"{k} is not a valid identifier")
|
| 542 |
+
if keyword.iskeyword(k):
|
| 543 |
+
raise ValueError(f"{k} is a python keyword")
|
| 544 |
+
|
| 545 |
+
cursor = _global_config
|
| 546 |
+
msg = "Path prefix to option '{option}' is already an option"
|
| 547 |
+
|
| 548 |
+
for i, p in enumerate(path[:-1]):
|
| 549 |
+
if not isinstance(cursor, dict):
|
| 550 |
+
raise OptionError(msg.format(option=".".join(path[:i])))
|
| 551 |
+
if p not in cursor:
|
| 552 |
+
cursor[p] = {}
|
| 553 |
+
cursor = cursor[p]
|
| 554 |
+
|
| 555 |
+
if not isinstance(cursor, dict):
|
| 556 |
+
raise OptionError(msg.format(option=".".join(path[:-1])))
|
| 557 |
+
|
| 558 |
+
cursor[path[-1]] = defval # initialize
|
| 559 |
+
|
| 560 |
+
# save the option metadata
|
| 561 |
+
_registered_options[key] = RegisteredOption(
|
| 562 |
+
key=key, defval=defval, doc=doc, validator=validator, cb=cb
|
| 563 |
+
)
|
| 564 |
+
|
| 565 |
+
|
| 566 |
+
def deprecate_option(
|
| 567 |
+
key: str,
|
| 568 |
+
msg: str | None = None,
|
| 569 |
+
rkey: str | None = None,
|
| 570 |
+
removal_ver: str | None = None,
|
| 571 |
+
) -> None:
|
| 572 |
+
"""
|
| 573 |
+
Mark option `key` as deprecated, if code attempts to access this option,
|
| 574 |
+
a warning will be produced, using `msg` if given, or a default message
|
| 575 |
+
if not.
|
| 576 |
+
if `rkey` is given, any access to the key will be re-routed to `rkey`.
|
| 577 |
+
|
| 578 |
+
Neither the existence of `key` nor that if `rkey` is checked. If they
|
| 579 |
+
do not exist, any subsequence access will fail as usual, after the
|
| 580 |
+
deprecation warning is given.
|
| 581 |
+
|
| 582 |
+
Parameters
|
| 583 |
+
----------
|
| 584 |
+
key : str
|
| 585 |
+
Name of the option to be deprecated.
|
| 586 |
+
must be a fully-qualified option name (e.g "x.y.z.rkey").
|
| 587 |
+
msg : str, optional
|
| 588 |
+
Warning message to output when the key is referenced.
|
| 589 |
+
if no message is given a default message will be emitted.
|
| 590 |
+
rkey : str, optional
|
| 591 |
+
Name of an option to reroute access to.
|
| 592 |
+
If specified, any referenced `key` will be
|
| 593 |
+
re-routed to `rkey` including set/get/reset.
|
| 594 |
+
rkey must be a fully-qualified option name (e.g "x.y.z.rkey").
|
| 595 |
+
used by the default message if no `msg` is specified.
|
| 596 |
+
removal_ver : str, optional
|
| 597 |
+
Specifies the version in which this option will
|
| 598 |
+
be removed. used by the default message if no `msg` is specified.
|
| 599 |
+
|
| 600 |
+
Raises
|
| 601 |
+
------
|
| 602 |
+
OptionError
|
| 603 |
+
If the specified key has already been deprecated.
|
| 604 |
+
"""
|
| 605 |
+
key = key.lower()
|
| 606 |
+
|
| 607 |
+
if key in _deprecated_options:
|
| 608 |
+
raise OptionError(f"Option '{key}' has already been defined as deprecated.")
|
| 609 |
+
|
| 610 |
+
_deprecated_options[key] = DeprecatedOption(key, msg, rkey, removal_ver)
|
| 611 |
+
|
| 612 |
+
|
| 613 |
+
#
|
| 614 |
+
# functions internal to the module
|
| 615 |
+
|
| 616 |
+
|
| 617 |
+
def _select_options(pat: str) -> list[str]:
|
| 618 |
+
"""
|
| 619 |
+
returns a list of keys matching `pat`
|
| 620 |
+
|
| 621 |
+
if pat=="all", returns all registered options
|
| 622 |
+
"""
|
| 623 |
+
# short-circuit for exact key
|
| 624 |
+
if pat in _registered_options:
|
| 625 |
+
return [pat]
|
| 626 |
+
|
| 627 |
+
# else look through all of them
|
| 628 |
+
keys = sorted(_registered_options.keys())
|
| 629 |
+
if pat == "all": # reserved key
|
| 630 |
+
return keys
|
| 631 |
+
|
| 632 |
+
return [k for k in keys if re.search(pat, k, re.I)]
|
| 633 |
+
|
| 634 |
+
|
| 635 |
+
def _get_root(key: str) -> tuple[dict[str, Any], str]:
|
| 636 |
+
path = key.split(".")
|
| 637 |
+
cursor = _global_config
|
| 638 |
+
for p in path[:-1]:
|
| 639 |
+
cursor = cursor[p]
|
| 640 |
+
return cursor, path[-1]
|
| 641 |
+
|
| 642 |
+
|
| 643 |
+
def _is_deprecated(key: str) -> bool:
|
| 644 |
+
"""Returns True if the given option has been deprecated"""
|
| 645 |
+
key = key.lower()
|
| 646 |
+
return key in _deprecated_options
|
| 647 |
+
|
| 648 |
+
|
| 649 |
+
def _get_deprecated_option(key: str):
|
| 650 |
+
"""
|
| 651 |
+
Retrieves the metadata for a deprecated option, if `key` is deprecated.
|
| 652 |
+
|
| 653 |
+
Returns
|
| 654 |
+
-------
|
| 655 |
+
DeprecatedOption (namedtuple) if key is deprecated, None otherwise
|
| 656 |
+
"""
|
| 657 |
+
try:
|
| 658 |
+
d = _deprecated_options[key]
|
| 659 |
+
except KeyError:
|
| 660 |
+
return None
|
| 661 |
+
else:
|
| 662 |
+
return d
|
| 663 |
+
|
| 664 |
+
|
| 665 |
+
def _get_registered_option(key: str):
|
| 666 |
+
"""
|
| 667 |
+
Retrieves the option metadata if `key` is a registered option.
|
| 668 |
+
|
| 669 |
+
Returns
|
| 670 |
+
-------
|
| 671 |
+
RegisteredOption (namedtuple) if key is deprecated, None otherwise
|
| 672 |
+
"""
|
| 673 |
+
return _registered_options.get(key)
|
| 674 |
+
|
| 675 |
+
|
| 676 |
+
def _translate_key(key: str) -> str:
|
| 677 |
+
"""
|
| 678 |
+
if key id deprecated and a replacement key defined, will return the
|
| 679 |
+
replacement key, otherwise returns `key` as - is
|
| 680 |
+
"""
|
| 681 |
+
d = _get_deprecated_option(key)
|
| 682 |
+
if d:
|
| 683 |
+
return d.rkey or key
|
| 684 |
+
else:
|
| 685 |
+
return key
|
| 686 |
+
|
| 687 |
+
|
| 688 |
+
def _warn_if_deprecated(key: str) -> bool:
|
| 689 |
+
"""
|
| 690 |
+
Checks if `key` is a deprecated option and if so, prints a warning.
|
| 691 |
+
|
| 692 |
+
Returns
|
| 693 |
+
-------
|
| 694 |
+
bool - True if `key` is deprecated, False otherwise.
|
| 695 |
+
"""
|
| 696 |
+
d = _get_deprecated_option(key)
|
| 697 |
+
if d:
|
| 698 |
+
if d.msg:
|
| 699 |
+
warnings.warn(
|
| 700 |
+
d.msg,
|
| 701 |
+
FutureWarning,
|
| 702 |
+
stacklevel=find_stack_level(),
|
| 703 |
+
)
|
| 704 |
+
else:
|
| 705 |
+
msg = f"'{key}' is deprecated"
|
| 706 |
+
if d.removal_ver:
|
| 707 |
+
msg += f" and will be removed in {d.removal_ver}"
|
| 708 |
+
if d.rkey:
|
| 709 |
+
msg += f", please use '{d.rkey}' instead."
|
| 710 |
+
else:
|
| 711 |
+
msg += ", please refrain from using it."
|
| 712 |
+
|
| 713 |
+
warnings.warn(msg, FutureWarning, stacklevel=find_stack_level())
|
| 714 |
+
return True
|
| 715 |
+
return False
|
| 716 |
+
|
| 717 |
+
|
| 718 |
+
def _build_option_description(k: str) -> str:
|
| 719 |
+
"""Builds a formatted description of a registered option and prints it"""
|
| 720 |
+
o = _get_registered_option(k)
|
| 721 |
+
d = _get_deprecated_option(k)
|
| 722 |
+
|
| 723 |
+
s = f"{k} "
|
| 724 |
+
|
| 725 |
+
if o.doc:
|
| 726 |
+
s += "\n".join(o.doc.strip().split("\n"))
|
| 727 |
+
else:
|
| 728 |
+
s += "No description available."
|
| 729 |
+
|
| 730 |
+
if o:
|
| 731 |
+
s += f"\n [default: {o.defval}] [currently: {_get_option(k, True)}]"
|
| 732 |
+
|
| 733 |
+
if d:
|
| 734 |
+
rkey = d.rkey or ""
|
| 735 |
+
s += "\n (Deprecated"
|
| 736 |
+
s += f", use `{rkey}` instead."
|
| 737 |
+
s += ")"
|
| 738 |
+
|
| 739 |
+
return s
|
| 740 |
+
|
| 741 |
+
|
| 742 |
+
def pp_options_list(keys: Iterable[str], width: int = 80, _print: bool = False):
|
| 743 |
+
"""Builds a concise listing of available options, grouped by prefix"""
|
| 744 |
+
from itertools import groupby
|
| 745 |
+
from textwrap import wrap
|
| 746 |
+
|
| 747 |
+
def pp(name: str, ks: Iterable[str]) -> list[str]:
|
| 748 |
+
pfx = "- " + name + ".[" if name else ""
|
| 749 |
+
ls = wrap(
|
| 750 |
+
", ".join(ks),
|
| 751 |
+
width,
|
| 752 |
+
initial_indent=pfx,
|
| 753 |
+
subsequent_indent=" ",
|
| 754 |
+
break_long_words=False,
|
| 755 |
+
)
|
| 756 |
+
if ls and ls[-1] and name:
|
| 757 |
+
ls[-1] = ls[-1] + "]"
|
| 758 |
+
return ls
|
| 759 |
+
|
| 760 |
+
ls: list[str] = []
|
| 761 |
+
singles = [x for x in sorted(keys) if x.find(".") < 0]
|
| 762 |
+
if singles:
|
| 763 |
+
ls += pp("", singles)
|
| 764 |
+
keys = [x for x in keys if x.find(".") >= 0]
|
| 765 |
+
|
| 766 |
+
for k, g in groupby(sorted(keys), lambda x: x[: x.rfind(".")]):
|
| 767 |
+
ks = [x[len(k) + 1 :] for x in list(g)]
|
| 768 |
+
ls += pp(k, ks)
|
| 769 |
+
s = "\n".join(ls)
|
| 770 |
+
if _print:
|
| 771 |
+
print(s)
|
| 772 |
+
else:
|
| 773 |
+
return s
|
| 774 |
+
|
| 775 |
+
|
| 776 |
+
#
|
| 777 |
+
# helpers
|
| 778 |
+
|
| 779 |
+
|
| 780 |
+
@contextmanager
|
| 781 |
+
def config_prefix(prefix: str) -> Generator[None, None, None]:
|
| 782 |
+
"""
|
| 783 |
+
contextmanager for multiple invocations of API with a common prefix
|
| 784 |
+
|
| 785 |
+
supported API functions: (register / get / set )__option
|
| 786 |
+
|
| 787 |
+
Warning: This is not thread - safe, and won't work properly if you import
|
| 788 |
+
the API functions into your module using the "from x import y" construct.
|
| 789 |
+
|
| 790 |
+
Example
|
| 791 |
+
-------
|
| 792 |
+
import pandas._config.config as cf
|
| 793 |
+
with cf.config_prefix("display.font"):
|
| 794 |
+
cf.register_option("color", "red")
|
| 795 |
+
cf.register_option("size", " 5 pt")
|
| 796 |
+
cf.set_option(size, " 6 pt")
|
| 797 |
+
cf.get_option(size)
|
| 798 |
+
...
|
| 799 |
+
|
| 800 |
+
etc'
|
| 801 |
+
|
| 802 |
+
will register options "display.font.color", "display.font.size", set the
|
| 803 |
+
value of "display.font.size"... and so on.
|
| 804 |
+
"""
|
| 805 |
+
# Note: reset_option relies on set_option, and on key directly
|
| 806 |
+
# it does not fit in to this monkey-patching scheme
|
| 807 |
+
|
| 808 |
+
global register_option, get_option, set_option
|
| 809 |
+
|
| 810 |
+
def wrap(func: F) -> F:
|
| 811 |
+
def inner(key: str, *args, **kwds):
|
| 812 |
+
pkey = f"{prefix}.{key}"
|
| 813 |
+
return func(pkey, *args, **kwds)
|
| 814 |
+
|
| 815 |
+
return cast(F, inner)
|
| 816 |
+
|
| 817 |
+
_register_option = register_option
|
| 818 |
+
_get_option = get_option
|
| 819 |
+
_set_option = set_option
|
| 820 |
+
set_option = wrap(set_option)
|
| 821 |
+
get_option = wrap(get_option)
|
| 822 |
+
register_option = wrap(register_option)
|
| 823 |
+
try:
|
| 824 |
+
yield
|
| 825 |
+
finally:
|
| 826 |
+
set_option = _set_option
|
| 827 |
+
get_option = _get_option
|
| 828 |
+
register_option = _register_option
|
| 829 |
+
|
| 830 |
+
|
| 831 |
+
# These factories and methods are handy for use as the validator
|
| 832 |
+
# arg in register_option
|
| 833 |
+
|
| 834 |
+
|
| 835 |
+
def is_type_factory(_type: type[Any]) -> Callable[[Any], None]:
|
| 836 |
+
"""
|
| 837 |
+
|
| 838 |
+
Parameters
|
| 839 |
+
----------
|
| 840 |
+
`_type` - a type to be compared against (e.g. type(x) == `_type`)
|
| 841 |
+
|
| 842 |
+
Returns
|
| 843 |
+
-------
|
| 844 |
+
validator - a function of a single argument x , which raises
|
| 845 |
+
ValueError if type(x) is not equal to `_type`
|
| 846 |
+
|
| 847 |
+
"""
|
| 848 |
+
|
| 849 |
+
def inner(x) -> None:
|
| 850 |
+
if type(x) != _type:
|
| 851 |
+
raise ValueError(f"Value must have type '{_type}'")
|
| 852 |
+
|
| 853 |
+
return inner
|
| 854 |
+
|
| 855 |
+
|
| 856 |
+
def is_instance_factory(_type) -> Callable[[Any], None]:
|
| 857 |
+
"""
|
| 858 |
+
|
| 859 |
+
Parameters
|
| 860 |
+
----------
|
| 861 |
+
`_type` - the type to be checked against
|
| 862 |
+
|
| 863 |
+
Returns
|
| 864 |
+
-------
|
| 865 |
+
validator - a function of a single argument x , which raises
|
| 866 |
+
ValueError if x is not an instance of `_type`
|
| 867 |
+
|
| 868 |
+
"""
|
| 869 |
+
if isinstance(_type, (tuple, list)):
|
| 870 |
+
_type = tuple(_type)
|
| 871 |
+
type_repr = "|".join(map(str, _type))
|
| 872 |
+
else:
|
| 873 |
+
type_repr = f"'{_type}'"
|
| 874 |
+
|
| 875 |
+
def inner(x) -> None:
|
| 876 |
+
if not isinstance(x, _type):
|
| 877 |
+
raise ValueError(f"Value must be an instance of {type_repr}")
|
| 878 |
+
|
| 879 |
+
return inner
|
| 880 |
+
|
| 881 |
+
|
| 882 |
+
def is_one_of_factory(legal_values) -> Callable[[Any], None]:
|
| 883 |
+
callables = [c for c in legal_values if callable(c)]
|
| 884 |
+
legal_values = [c for c in legal_values if not callable(c)]
|
| 885 |
+
|
| 886 |
+
def inner(x) -> None:
|
| 887 |
+
if x not in legal_values:
|
| 888 |
+
if not any(c(x) for c in callables):
|
| 889 |
+
uvals = [str(lval) for lval in legal_values]
|
| 890 |
+
pp_values = "|".join(uvals)
|
| 891 |
+
msg = f"Value must be one of {pp_values}"
|
| 892 |
+
if len(callables):
|
| 893 |
+
msg += " or a callable"
|
| 894 |
+
raise ValueError(msg)
|
| 895 |
+
|
| 896 |
+
return inner
|
| 897 |
+
|
| 898 |
+
|
| 899 |
+
def is_nonnegative_int(value: object) -> None:
|
| 900 |
+
"""
|
| 901 |
+
Verify that value is None or a positive int.
|
| 902 |
+
|
| 903 |
+
Parameters
|
| 904 |
+
----------
|
| 905 |
+
value : None or int
|
| 906 |
+
The `value` to be checked.
|
| 907 |
+
|
| 908 |
+
Raises
|
| 909 |
+
------
|
| 910 |
+
ValueError
|
| 911 |
+
When the value is not None or is a negative integer
|
| 912 |
+
"""
|
| 913 |
+
if value is None:
|
| 914 |
+
return
|
| 915 |
+
|
| 916 |
+
elif isinstance(value, int):
|
| 917 |
+
if value >= 0:
|
| 918 |
+
return
|
| 919 |
+
|
| 920 |
+
msg = "Value must be a nonnegative integer or None"
|
| 921 |
+
raise ValueError(msg)
|
| 922 |
+
|
| 923 |
+
|
| 924 |
+
# common type validators, for convenience
|
| 925 |
+
# usage: register_option(... , validator = is_int)
|
| 926 |
+
is_int = is_type_factory(int)
|
| 927 |
+
is_bool = is_type_factory(bool)
|
| 928 |
+
is_float = is_type_factory(float)
|
| 929 |
+
is_str = is_type_factory(str)
|
| 930 |
+
is_text = is_instance_factory((str, bytes))
|
| 931 |
+
|
| 932 |
+
|
| 933 |
+
def is_callable(obj) -> bool:
|
| 934 |
+
"""
|
| 935 |
+
|
| 936 |
+
Parameters
|
| 937 |
+
----------
|
| 938 |
+
`obj` - the object to be checked
|
| 939 |
+
|
| 940 |
+
Returns
|
| 941 |
+
-------
|
| 942 |
+
validator - returns True if object is callable
|
| 943 |
+
raises ValueError otherwise.
|
| 944 |
+
|
| 945 |
+
"""
|
| 946 |
+
if not callable(obj):
|
| 947 |
+
raise ValueError("Value must be a callable")
|
| 948 |
+
return True
|
lib/python3.12/site-packages/pandas/_config/dates.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
config for datetime formatting
|
| 3 |
+
"""
|
| 4 |
+
from __future__ import annotations
|
| 5 |
+
|
| 6 |
+
from pandas._config import config as cf
|
| 7 |
+
|
| 8 |
+
pc_date_dayfirst_doc = """
|
| 9 |
+
: boolean
|
| 10 |
+
When True, prints and parses dates with the day first, eg 20/01/2005
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
pc_date_yearfirst_doc = """
|
| 14 |
+
: boolean
|
| 15 |
+
When True, prints and parses dates with the year first, eg 2005/01/20
|
| 16 |
+
"""
|
| 17 |
+
|
| 18 |
+
with cf.config_prefix("display"):
|
| 19 |
+
# Needed upstream of `_libs` because these are used in tslibs.parsing
|
| 20 |
+
cf.register_option(
|
| 21 |
+
"date_dayfirst", False, pc_date_dayfirst_doc, validator=cf.is_bool
|
| 22 |
+
)
|
| 23 |
+
cf.register_option(
|
| 24 |
+
"date_yearfirst", False, pc_date_yearfirst_doc, validator=cf.is_bool
|
| 25 |
+
)
|
lib/python3.12/site-packages/pandas/_config/display.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Unopinionated display configuration.
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
from __future__ import annotations
|
| 6 |
+
|
| 7 |
+
import locale
|
| 8 |
+
import sys
|
| 9 |
+
|
| 10 |
+
from pandas._config import config as cf
|
| 11 |
+
|
| 12 |
+
# -----------------------------------------------------------------------------
|
| 13 |
+
# Global formatting options
|
| 14 |
+
_initial_defencoding: str | None = None
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def detect_console_encoding() -> str:
|
| 18 |
+
"""
|
| 19 |
+
Try to find the most capable encoding supported by the console.
|
| 20 |
+
slightly modified from the way IPython handles the same issue.
|
| 21 |
+
"""
|
| 22 |
+
global _initial_defencoding
|
| 23 |
+
|
| 24 |
+
encoding = None
|
| 25 |
+
try:
|
| 26 |
+
encoding = sys.stdout.encoding or sys.stdin.encoding
|
| 27 |
+
except (AttributeError, OSError):
|
| 28 |
+
pass
|
| 29 |
+
|
| 30 |
+
# try again for something better
|
| 31 |
+
if not encoding or "ascii" in encoding.lower():
|
| 32 |
+
try:
|
| 33 |
+
encoding = locale.getpreferredencoding()
|
| 34 |
+
except locale.Error:
|
| 35 |
+
# can be raised by locale.setlocale(), which is
|
| 36 |
+
# called by getpreferredencoding
|
| 37 |
+
# (on some systems, see stdlib locale docs)
|
| 38 |
+
pass
|
| 39 |
+
|
| 40 |
+
# when all else fails. this will usually be "ascii"
|
| 41 |
+
if not encoding or "ascii" in encoding.lower():
|
| 42 |
+
encoding = sys.getdefaultencoding()
|
| 43 |
+
|
| 44 |
+
# GH#3360, save the reported defencoding at import time
|
| 45 |
+
# MPL backends may change it. Make available for debugging.
|
| 46 |
+
if not _initial_defencoding:
|
| 47 |
+
_initial_defencoding = sys.getdefaultencoding()
|
| 48 |
+
|
| 49 |
+
return encoding
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
pc_encoding_doc = """
|
| 53 |
+
: str/unicode
|
| 54 |
+
Defaults to the detected encoding of the console.
|
| 55 |
+
Specifies the encoding to be used for strings returned by to_string,
|
| 56 |
+
these are generally strings meant to be displayed on the console.
|
| 57 |
+
"""
|
| 58 |
+
|
| 59 |
+
with cf.config_prefix("display"):
|
| 60 |
+
cf.register_option(
|
| 61 |
+
"encoding", detect_console_encoding(), pc_encoding_doc, validator=cf.is_text
|
| 62 |
+
)
|
lib/python3.12/site-packages/pandas/_config/localization.py
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Helpers for configuring locale settings.
|
| 3 |
+
|
| 4 |
+
Name `localization` is chosen to avoid overlap with builtin `locale` module.
|
| 5 |
+
"""
|
| 6 |
+
from __future__ import annotations
|
| 7 |
+
|
| 8 |
+
from contextlib import contextmanager
|
| 9 |
+
import locale
|
| 10 |
+
import platform
|
| 11 |
+
import re
|
| 12 |
+
import subprocess
|
| 13 |
+
from typing import TYPE_CHECKING
|
| 14 |
+
|
| 15 |
+
from pandas._config.config import options
|
| 16 |
+
|
| 17 |
+
if TYPE_CHECKING:
|
| 18 |
+
from collections.abc import Generator
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
@contextmanager
|
| 22 |
+
def set_locale(
|
| 23 |
+
new_locale: str | tuple[str, str], lc_var: int = locale.LC_ALL
|
| 24 |
+
) -> Generator[str | tuple[str, str], None, None]:
|
| 25 |
+
"""
|
| 26 |
+
Context manager for temporarily setting a locale.
|
| 27 |
+
|
| 28 |
+
Parameters
|
| 29 |
+
----------
|
| 30 |
+
new_locale : str or tuple
|
| 31 |
+
A string of the form <language_country>.<encoding>. For example to set
|
| 32 |
+
the current locale to US English with a UTF8 encoding, you would pass
|
| 33 |
+
"en_US.UTF-8".
|
| 34 |
+
lc_var : int, default `locale.LC_ALL`
|
| 35 |
+
The category of the locale being set.
|
| 36 |
+
|
| 37 |
+
Notes
|
| 38 |
+
-----
|
| 39 |
+
This is useful when you want to run a particular block of code under a
|
| 40 |
+
particular locale, without globally setting the locale. This probably isn't
|
| 41 |
+
thread-safe.
|
| 42 |
+
"""
|
| 43 |
+
# getlocale is not always compliant with setlocale, use setlocale. GH#46595
|
| 44 |
+
current_locale = locale.setlocale(lc_var)
|
| 45 |
+
|
| 46 |
+
try:
|
| 47 |
+
locale.setlocale(lc_var, new_locale)
|
| 48 |
+
normalized_code, normalized_encoding = locale.getlocale()
|
| 49 |
+
if normalized_code is not None and normalized_encoding is not None:
|
| 50 |
+
yield f"{normalized_code}.{normalized_encoding}"
|
| 51 |
+
else:
|
| 52 |
+
yield new_locale
|
| 53 |
+
finally:
|
| 54 |
+
locale.setlocale(lc_var, current_locale)
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
def can_set_locale(lc: str, lc_var: int = locale.LC_ALL) -> bool:
|
| 58 |
+
"""
|
| 59 |
+
Check to see if we can set a locale, and subsequently get the locale,
|
| 60 |
+
without raising an Exception.
|
| 61 |
+
|
| 62 |
+
Parameters
|
| 63 |
+
----------
|
| 64 |
+
lc : str
|
| 65 |
+
The locale to attempt to set.
|
| 66 |
+
lc_var : int, default `locale.LC_ALL`
|
| 67 |
+
The category of the locale being set.
|
| 68 |
+
|
| 69 |
+
Returns
|
| 70 |
+
-------
|
| 71 |
+
bool
|
| 72 |
+
Whether the passed locale can be set
|
| 73 |
+
"""
|
| 74 |
+
try:
|
| 75 |
+
with set_locale(lc, lc_var=lc_var):
|
| 76 |
+
pass
|
| 77 |
+
except (ValueError, locale.Error):
|
| 78 |
+
# horrible name for a Exception subclass
|
| 79 |
+
return False
|
| 80 |
+
else:
|
| 81 |
+
return True
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
def _valid_locales(locales: list[str] | str, normalize: bool) -> list[str]:
|
| 85 |
+
"""
|
| 86 |
+
Return a list of normalized locales that do not throw an ``Exception``
|
| 87 |
+
when set.
|
| 88 |
+
|
| 89 |
+
Parameters
|
| 90 |
+
----------
|
| 91 |
+
locales : str
|
| 92 |
+
A string where each locale is separated by a newline.
|
| 93 |
+
normalize : bool
|
| 94 |
+
Whether to call ``locale.normalize`` on each locale.
|
| 95 |
+
|
| 96 |
+
Returns
|
| 97 |
+
-------
|
| 98 |
+
valid_locales : list
|
| 99 |
+
A list of valid locales.
|
| 100 |
+
"""
|
| 101 |
+
return [
|
| 102 |
+
loc
|
| 103 |
+
for loc in (
|
| 104 |
+
locale.normalize(loc.strip()) if normalize else loc.strip()
|
| 105 |
+
for loc in locales
|
| 106 |
+
)
|
| 107 |
+
if can_set_locale(loc)
|
| 108 |
+
]
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
def get_locales(
|
| 112 |
+
prefix: str | None = None,
|
| 113 |
+
normalize: bool = True,
|
| 114 |
+
) -> list[str]:
|
| 115 |
+
"""
|
| 116 |
+
Get all the locales that are available on the system.
|
| 117 |
+
|
| 118 |
+
Parameters
|
| 119 |
+
----------
|
| 120 |
+
prefix : str
|
| 121 |
+
If not ``None`` then return only those locales with the prefix
|
| 122 |
+
provided. For example to get all English language locales (those that
|
| 123 |
+
start with ``"en"``), pass ``prefix="en"``.
|
| 124 |
+
normalize : bool
|
| 125 |
+
Call ``locale.normalize`` on the resulting list of available locales.
|
| 126 |
+
If ``True``, only locales that can be set without throwing an
|
| 127 |
+
``Exception`` are returned.
|
| 128 |
+
|
| 129 |
+
Returns
|
| 130 |
+
-------
|
| 131 |
+
locales : list of strings
|
| 132 |
+
A list of locale strings that can be set with ``locale.setlocale()``.
|
| 133 |
+
For example::
|
| 134 |
+
|
| 135 |
+
locale.setlocale(locale.LC_ALL, locale_string)
|
| 136 |
+
|
| 137 |
+
On error will return an empty list (no locale available, e.g. Windows)
|
| 138 |
+
|
| 139 |
+
"""
|
| 140 |
+
if platform.system() in ("Linux", "Darwin"):
|
| 141 |
+
raw_locales = subprocess.check_output(["locale", "-a"])
|
| 142 |
+
else:
|
| 143 |
+
# Other platforms e.g. windows platforms don't define "locale -a"
|
| 144 |
+
# Note: is_platform_windows causes circular import here
|
| 145 |
+
return []
|
| 146 |
+
|
| 147 |
+
try:
|
| 148 |
+
# raw_locales is "\n" separated list of locales
|
| 149 |
+
# it may contain non-decodable parts, so split
|
| 150 |
+
# extract what we can and then rejoin.
|
| 151 |
+
split_raw_locales = raw_locales.split(b"\n")
|
| 152 |
+
out_locales = []
|
| 153 |
+
for x in split_raw_locales:
|
| 154 |
+
try:
|
| 155 |
+
out_locales.append(str(x, encoding=options.display.encoding))
|
| 156 |
+
except UnicodeError:
|
| 157 |
+
# 'locale -a' is used to populated 'raw_locales' and on
|
| 158 |
+
# Redhat 7 Linux (and maybe others) prints locale names
|
| 159 |
+
# using windows-1252 encoding. Bug only triggered by
|
| 160 |
+
# a few special characters and when there is an
|
| 161 |
+
# extensive list of installed locales.
|
| 162 |
+
out_locales.append(str(x, encoding="windows-1252"))
|
| 163 |
+
|
| 164 |
+
except TypeError:
|
| 165 |
+
pass
|
| 166 |
+
|
| 167 |
+
if prefix is None:
|
| 168 |
+
return _valid_locales(out_locales, normalize)
|
| 169 |
+
|
| 170 |
+
pattern = re.compile(f"{prefix}.*")
|
| 171 |
+
found = pattern.findall("\n".join(out_locales))
|
| 172 |
+
return _valid_locales(found, normalize)
|
lib/python3.12/site-packages/pandas/_libs/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (584 Bytes). View file
|
|
|
lib/python3.12/site-packages/pandas/_libs/tslibs/__init__.py
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
__all__ = [
|
| 2 |
+
"dtypes",
|
| 3 |
+
"localize_pydatetime",
|
| 4 |
+
"NaT",
|
| 5 |
+
"NaTType",
|
| 6 |
+
"iNaT",
|
| 7 |
+
"nat_strings",
|
| 8 |
+
"OutOfBoundsDatetime",
|
| 9 |
+
"OutOfBoundsTimedelta",
|
| 10 |
+
"IncompatibleFrequency",
|
| 11 |
+
"Period",
|
| 12 |
+
"Resolution",
|
| 13 |
+
"Timedelta",
|
| 14 |
+
"normalize_i8_timestamps",
|
| 15 |
+
"is_date_array_normalized",
|
| 16 |
+
"dt64arr_to_periodarr",
|
| 17 |
+
"delta_to_nanoseconds",
|
| 18 |
+
"ints_to_pydatetime",
|
| 19 |
+
"ints_to_pytimedelta",
|
| 20 |
+
"get_resolution",
|
| 21 |
+
"Timestamp",
|
| 22 |
+
"tz_convert_from_utc_single",
|
| 23 |
+
"tz_convert_from_utc",
|
| 24 |
+
"to_offset",
|
| 25 |
+
"Tick",
|
| 26 |
+
"BaseOffset",
|
| 27 |
+
"tz_compare",
|
| 28 |
+
"is_unitless",
|
| 29 |
+
"astype_overflowsafe",
|
| 30 |
+
"get_unit_from_dtype",
|
| 31 |
+
"periods_per_day",
|
| 32 |
+
"periods_per_second",
|
| 33 |
+
"guess_datetime_format",
|
| 34 |
+
"add_overflowsafe",
|
| 35 |
+
"get_supported_dtype",
|
| 36 |
+
"is_supported_dtype",
|
| 37 |
+
]
|
| 38 |
+
|
| 39 |
+
from pandas._libs.tslibs import dtypes # pylint: disable=import-self
|
| 40 |
+
from pandas._libs.tslibs.conversion import localize_pydatetime
|
| 41 |
+
from pandas._libs.tslibs.dtypes import (
|
| 42 |
+
Resolution,
|
| 43 |
+
periods_per_day,
|
| 44 |
+
periods_per_second,
|
| 45 |
+
)
|
| 46 |
+
from pandas._libs.tslibs.nattype import (
|
| 47 |
+
NaT,
|
| 48 |
+
NaTType,
|
| 49 |
+
iNaT,
|
| 50 |
+
nat_strings,
|
| 51 |
+
)
|
| 52 |
+
from pandas._libs.tslibs.np_datetime import (
|
| 53 |
+
OutOfBoundsDatetime,
|
| 54 |
+
OutOfBoundsTimedelta,
|
| 55 |
+
add_overflowsafe,
|
| 56 |
+
astype_overflowsafe,
|
| 57 |
+
get_supported_dtype,
|
| 58 |
+
is_supported_dtype,
|
| 59 |
+
is_unitless,
|
| 60 |
+
py_get_unit_from_dtype as get_unit_from_dtype,
|
| 61 |
+
)
|
| 62 |
+
from pandas._libs.tslibs.offsets import (
|
| 63 |
+
BaseOffset,
|
| 64 |
+
Tick,
|
| 65 |
+
to_offset,
|
| 66 |
+
)
|
| 67 |
+
from pandas._libs.tslibs.parsing import guess_datetime_format
|
| 68 |
+
from pandas._libs.tslibs.period import (
|
| 69 |
+
IncompatibleFrequency,
|
| 70 |
+
Period,
|
| 71 |
+
)
|
| 72 |
+
from pandas._libs.tslibs.timedeltas import (
|
| 73 |
+
Timedelta,
|
| 74 |
+
delta_to_nanoseconds,
|
| 75 |
+
ints_to_pytimedelta,
|
| 76 |
+
)
|
| 77 |
+
from pandas._libs.tslibs.timestamps import Timestamp
|
| 78 |
+
from pandas._libs.tslibs.timezones import tz_compare
|
| 79 |
+
from pandas._libs.tslibs.tzconversion import tz_convert_from_utc_single
|
| 80 |
+
from pandas._libs.tslibs.vectorized import (
|
| 81 |
+
dt64arr_to_periodarr,
|
| 82 |
+
get_resolution,
|
| 83 |
+
ints_to_pydatetime,
|
| 84 |
+
is_date_array_normalized,
|
| 85 |
+
normalize_i8_timestamps,
|
| 86 |
+
tz_convert_from_utc,
|
| 87 |
+
)
|
lib/python3.12/site-packages/pandas/_libs/tslibs/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (1.95 kB). View file
|
|
|
lib/python3.12/site-packages/pandas/_libs/tslibs/base.cpython-312-x86_64-linux-gnu.so
ADDED
|
Binary file (66.4 kB). View file
|
|
|
lib/python3.12/site-packages/pandas/_libs/tslibs/ccalendar.pyi
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
DAYS: list[str]
|
| 2 |
+
MONTH_ALIASES: dict[int, str]
|
| 3 |
+
MONTH_NUMBERS: dict[str, int]
|
| 4 |
+
MONTHS: list[str]
|
| 5 |
+
int_to_weekday: dict[int, str]
|
| 6 |
+
|
| 7 |
+
def get_firstbday(year: int, month: int) -> int: ...
|
| 8 |
+
def get_lastbday(year: int, month: int) -> int: ...
|
| 9 |
+
def get_day_of_year(year: int, month: int, day: int) -> int: ...
|
| 10 |
+
def get_iso_calendar(year: int, month: int, day: int) -> tuple[int, int, int]: ...
|
| 11 |
+
def get_week_of_year(year: int, month: int, day: int) -> int: ...
|
| 12 |
+
def get_days_in_month(year: int, month: int) -> int: ...
|
lib/python3.12/site-packages/pandas/_libs/tslibs/conversion.pyi
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from datetime import (
|
| 2 |
+
datetime,
|
| 3 |
+
tzinfo,
|
| 4 |
+
)
|
| 5 |
+
|
| 6 |
+
import numpy as np
|
| 7 |
+
|
| 8 |
+
DT64NS_DTYPE: np.dtype
|
| 9 |
+
TD64NS_DTYPE: np.dtype
|
| 10 |
+
|
| 11 |
+
def localize_pydatetime(dt: datetime, tz: tzinfo | None) -> datetime: ...
|
| 12 |
+
def cast_from_unit_vectorized(
|
| 13 |
+
values: np.ndarray, unit: str, out_unit: str = ...
|
| 14 |
+
) -> np.ndarray: ...
|
lib/python3.12/site-packages/pandas/_libs/tslibs/dtypes.pyi
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from enum import Enum
|
| 2 |
+
|
| 3 |
+
OFFSET_TO_PERIOD_FREQSTR: dict[str, str]
|
| 4 |
+
|
| 5 |
+
def periods_per_day(reso: int = ...) -> int: ...
|
| 6 |
+
def periods_per_second(reso: int) -> int: ...
|
| 7 |
+
def abbrev_to_npy_unit(abbrev: str | None) -> int: ...
|
| 8 |
+
def freq_to_period_freqstr(freq_n: int, freq_name: str) -> str: ...
|
| 9 |
+
|
| 10 |
+
class PeriodDtypeBase:
|
| 11 |
+
_dtype_code: int # PeriodDtypeCode
|
| 12 |
+
_n: int
|
| 13 |
+
|
| 14 |
+
# actually __cinit__
|
| 15 |
+
def __new__(cls, code: int, n: int): ...
|
| 16 |
+
@property
|
| 17 |
+
def _freq_group_code(self) -> int: ...
|
| 18 |
+
@property
|
| 19 |
+
def _resolution_obj(self) -> Resolution: ...
|
| 20 |
+
def _get_to_timestamp_base(self) -> int: ...
|
| 21 |
+
@property
|
| 22 |
+
def _freqstr(self) -> str: ...
|
| 23 |
+
def __hash__(self) -> int: ...
|
| 24 |
+
def _is_tick_like(self) -> bool: ...
|
| 25 |
+
@property
|
| 26 |
+
def _creso(self) -> int: ...
|
| 27 |
+
@property
|
| 28 |
+
def _td64_unit(self) -> str: ...
|
| 29 |
+
|
| 30 |
+
class FreqGroup(Enum):
|
| 31 |
+
FR_ANN: int
|
| 32 |
+
FR_QTR: int
|
| 33 |
+
FR_MTH: int
|
| 34 |
+
FR_WK: int
|
| 35 |
+
FR_BUS: int
|
| 36 |
+
FR_DAY: int
|
| 37 |
+
FR_HR: int
|
| 38 |
+
FR_MIN: int
|
| 39 |
+
FR_SEC: int
|
| 40 |
+
FR_MS: int
|
| 41 |
+
FR_US: int
|
| 42 |
+
FR_NS: int
|
| 43 |
+
FR_UND: int
|
| 44 |
+
@staticmethod
|
| 45 |
+
def from_period_dtype_code(code: int) -> FreqGroup: ...
|
| 46 |
+
|
| 47 |
+
class Resolution(Enum):
|
| 48 |
+
RESO_NS: int
|
| 49 |
+
RESO_US: int
|
| 50 |
+
RESO_MS: int
|
| 51 |
+
RESO_SEC: int
|
| 52 |
+
RESO_MIN: int
|
| 53 |
+
RESO_HR: int
|
| 54 |
+
RESO_DAY: int
|
| 55 |
+
RESO_MTH: int
|
| 56 |
+
RESO_QTR: int
|
| 57 |
+
RESO_YR: int
|
| 58 |
+
def __lt__(self, other: Resolution) -> bool: ...
|
| 59 |
+
def __ge__(self, other: Resolution) -> bool: ...
|
| 60 |
+
@property
|
| 61 |
+
def attrname(self) -> str: ...
|
| 62 |
+
@classmethod
|
| 63 |
+
def from_attrname(cls, attrname: str) -> Resolution: ...
|
| 64 |
+
@classmethod
|
| 65 |
+
def get_reso_from_freqstr(cls, freq: str) -> Resolution: ...
|
| 66 |
+
@property
|
| 67 |
+
def attr_abbrev(self) -> str: ...
|
| 68 |
+
|
| 69 |
+
class NpyDatetimeUnit(Enum):
|
| 70 |
+
NPY_FR_Y: int
|
| 71 |
+
NPY_FR_M: int
|
| 72 |
+
NPY_FR_W: int
|
| 73 |
+
NPY_FR_D: int
|
| 74 |
+
NPY_FR_h: int
|
| 75 |
+
NPY_FR_m: int
|
| 76 |
+
NPY_FR_s: int
|
| 77 |
+
NPY_FR_ms: int
|
| 78 |
+
NPY_FR_us: int
|
| 79 |
+
NPY_FR_ns: int
|
| 80 |
+
NPY_FR_ps: int
|
| 81 |
+
NPY_FR_fs: int
|
| 82 |
+
NPY_FR_as: int
|
| 83 |
+
NPY_FR_GENERIC: int
|
lib/python3.12/site-packages/pandas/_libs/tslibs/fields.pyi
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
|
| 3 |
+
from pandas._typing import npt
|
| 4 |
+
|
| 5 |
+
def build_field_sarray(
|
| 6 |
+
dtindex: npt.NDArray[np.int64], # const int64_t[:]
|
| 7 |
+
reso: int, # NPY_DATETIMEUNIT
|
| 8 |
+
) -> np.ndarray: ...
|
| 9 |
+
def month_position_check(fields, weekdays) -> str | None: ...
|
| 10 |
+
def get_date_name_field(
|
| 11 |
+
dtindex: npt.NDArray[np.int64], # const int64_t[:]
|
| 12 |
+
field: str,
|
| 13 |
+
locale: str | None = ...,
|
| 14 |
+
reso: int = ..., # NPY_DATETIMEUNIT
|
| 15 |
+
) -> npt.NDArray[np.object_]: ...
|
| 16 |
+
def get_start_end_field(
|
| 17 |
+
dtindex: npt.NDArray[np.int64],
|
| 18 |
+
field: str,
|
| 19 |
+
freqstr: str | None = ...,
|
| 20 |
+
month_kw: int = ...,
|
| 21 |
+
reso: int = ..., # NPY_DATETIMEUNIT
|
| 22 |
+
) -> npt.NDArray[np.bool_]: ...
|
| 23 |
+
def get_date_field(
|
| 24 |
+
dtindex: npt.NDArray[np.int64], # const int64_t[:]
|
| 25 |
+
field: str,
|
| 26 |
+
reso: int = ..., # NPY_DATETIMEUNIT
|
| 27 |
+
) -> npt.NDArray[np.int32]: ...
|
| 28 |
+
def get_timedelta_field(
|
| 29 |
+
tdindex: npt.NDArray[np.int64], # const int64_t[:]
|
| 30 |
+
field: str,
|
| 31 |
+
reso: int = ..., # NPY_DATETIMEUNIT
|
| 32 |
+
) -> npt.NDArray[np.int32]: ...
|
| 33 |
+
def get_timedelta_days(
|
| 34 |
+
tdindex: npt.NDArray[np.int64], # const int64_t[:]
|
| 35 |
+
reso: int = ..., # NPY_DATETIMEUNIT
|
| 36 |
+
) -> npt.NDArray[np.int64]: ...
|
| 37 |
+
def isleapyear_arr(
|
| 38 |
+
years: np.ndarray,
|
| 39 |
+
) -> npt.NDArray[np.bool_]: ...
|
| 40 |
+
def build_isocalendar_sarray(
|
| 41 |
+
dtindex: npt.NDArray[np.int64], # const int64_t[:]
|
| 42 |
+
reso: int, # NPY_DATETIMEUNIT
|
| 43 |
+
) -> np.ndarray: ...
|
| 44 |
+
def _get_locale_names(name_type: str, locale: str | None = ...): ...
|
| 45 |
+
|
| 46 |
+
class RoundTo:
|
| 47 |
+
@property
|
| 48 |
+
def MINUS_INFTY(self) -> int: ...
|
| 49 |
+
@property
|
| 50 |
+
def PLUS_INFTY(self) -> int: ...
|
| 51 |
+
@property
|
| 52 |
+
def NEAREST_HALF_EVEN(self) -> int: ...
|
| 53 |
+
@property
|
| 54 |
+
def NEAREST_HALF_PLUS_INFTY(self) -> int: ...
|
| 55 |
+
@property
|
| 56 |
+
def NEAREST_HALF_MINUS_INFTY(self) -> int: ...
|
| 57 |
+
|
| 58 |
+
def round_nsint64(
|
| 59 |
+
values: npt.NDArray[np.int64],
|
| 60 |
+
mode: RoundTo,
|
| 61 |
+
nanos: int,
|
| 62 |
+
) -> npt.NDArray[np.int64]: ...
|
lib/python3.12/site-packages/pandas/_libs/tslibs/nattype.pyi
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from datetime import (
|
| 2 |
+
datetime,
|
| 3 |
+
timedelta,
|
| 4 |
+
tzinfo as _tzinfo,
|
| 5 |
+
)
|
| 6 |
+
import typing
|
| 7 |
+
|
| 8 |
+
import numpy as np
|
| 9 |
+
|
| 10 |
+
from pandas._libs.tslibs.period import Period
|
| 11 |
+
from pandas._typing import Self
|
| 12 |
+
|
| 13 |
+
NaT: NaTType
|
| 14 |
+
iNaT: int
|
| 15 |
+
nat_strings: set[str]
|
| 16 |
+
|
| 17 |
+
_NaTComparisonTypes: typing.TypeAlias = (
|
| 18 |
+
datetime | timedelta | Period | np.datetime64 | np.timedelta64
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
class _NatComparison:
|
| 22 |
+
def __call__(self, other: _NaTComparisonTypes) -> bool: ...
|
| 23 |
+
|
| 24 |
+
class NaTType:
|
| 25 |
+
_value: np.int64
|
| 26 |
+
@property
|
| 27 |
+
def value(self) -> int: ...
|
| 28 |
+
@property
|
| 29 |
+
def asm8(self) -> np.datetime64: ...
|
| 30 |
+
def to_datetime64(self) -> np.datetime64: ...
|
| 31 |
+
def to_numpy(
|
| 32 |
+
self, dtype: np.dtype | str | None = ..., copy: bool = ...
|
| 33 |
+
) -> np.datetime64 | np.timedelta64: ...
|
| 34 |
+
@property
|
| 35 |
+
def is_leap_year(self) -> bool: ...
|
| 36 |
+
@property
|
| 37 |
+
def is_month_start(self) -> bool: ...
|
| 38 |
+
@property
|
| 39 |
+
def is_quarter_start(self) -> bool: ...
|
| 40 |
+
@property
|
| 41 |
+
def is_year_start(self) -> bool: ...
|
| 42 |
+
@property
|
| 43 |
+
def is_month_end(self) -> bool: ...
|
| 44 |
+
@property
|
| 45 |
+
def is_quarter_end(self) -> bool: ...
|
| 46 |
+
@property
|
| 47 |
+
def is_year_end(self) -> bool: ...
|
| 48 |
+
@property
|
| 49 |
+
def day_of_year(self) -> float: ...
|
| 50 |
+
@property
|
| 51 |
+
def dayofyear(self) -> float: ...
|
| 52 |
+
@property
|
| 53 |
+
def days_in_month(self) -> float: ...
|
| 54 |
+
@property
|
| 55 |
+
def daysinmonth(self) -> float: ...
|
| 56 |
+
@property
|
| 57 |
+
def day_of_week(self) -> float: ...
|
| 58 |
+
@property
|
| 59 |
+
def dayofweek(self) -> float: ...
|
| 60 |
+
@property
|
| 61 |
+
def week(self) -> float: ...
|
| 62 |
+
@property
|
| 63 |
+
def weekofyear(self) -> float: ...
|
| 64 |
+
def day_name(self) -> float: ...
|
| 65 |
+
def month_name(self) -> float: ...
|
| 66 |
+
def weekday(self) -> float: ...
|
| 67 |
+
def isoweekday(self) -> float: ...
|
| 68 |
+
def total_seconds(self) -> float: ...
|
| 69 |
+
def today(self, *args, **kwargs) -> NaTType: ...
|
| 70 |
+
def now(self, *args, **kwargs) -> NaTType: ...
|
| 71 |
+
def to_pydatetime(self) -> NaTType: ...
|
| 72 |
+
def date(self) -> NaTType: ...
|
| 73 |
+
def round(self) -> NaTType: ...
|
| 74 |
+
def floor(self) -> NaTType: ...
|
| 75 |
+
def ceil(self) -> NaTType: ...
|
| 76 |
+
@property
|
| 77 |
+
def tzinfo(self) -> None: ...
|
| 78 |
+
@property
|
| 79 |
+
def tz(self) -> None: ...
|
| 80 |
+
def tz_convert(self, tz: _tzinfo | str | None) -> NaTType: ...
|
| 81 |
+
def tz_localize(
|
| 82 |
+
self,
|
| 83 |
+
tz: _tzinfo | str | None,
|
| 84 |
+
ambiguous: str = ...,
|
| 85 |
+
nonexistent: str = ...,
|
| 86 |
+
) -> NaTType: ...
|
| 87 |
+
def replace(
|
| 88 |
+
self,
|
| 89 |
+
year: int | None = ...,
|
| 90 |
+
month: int | None = ...,
|
| 91 |
+
day: int | None = ...,
|
| 92 |
+
hour: int | None = ...,
|
| 93 |
+
minute: int | None = ...,
|
| 94 |
+
second: int | None = ...,
|
| 95 |
+
microsecond: int | None = ...,
|
| 96 |
+
nanosecond: int | None = ...,
|
| 97 |
+
tzinfo: _tzinfo | None = ...,
|
| 98 |
+
fold: int | None = ...,
|
| 99 |
+
) -> NaTType: ...
|
| 100 |
+
@property
|
| 101 |
+
def year(self) -> float: ...
|
| 102 |
+
@property
|
| 103 |
+
def quarter(self) -> float: ...
|
| 104 |
+
@property
|
| 105 |
+
def month(self) -> float: ...
|
| 106 |
+
@property
|
| 107 |
+
def day(self) -> float: ...
|
| 108 |
+
@property
|
| 109 |
+
def hour(self) -> float: ...
|
| 110 |
+
@property
|
| 111 |
+
def minute(self) -> float: ...
|
| 112 |
+
@property
|
| 113 |
+
def second(self) -> float: ...
|
| 114 |
+
@property
|
| 115 |
+
def millisecond(self) -> float: ...
|
| 116 |
+
@property
|
| 117 |
+
def microsecond(self) -> float: ...
|
| 118 |
+
@property
|
| 119 |
+
def nanosecond(self) -> float: ...
|
| 120 |
+
# inject Timedelta properties
|
| 121 |
+
@property
|
| 122 |
+
def days(self) -> float: ...
|
| 123 |
+
@property
|
| 124 |
+
def microseconds(self) -> float: ...
|
| 125 |
+
@property
|
| 126 |
+
def nanoseconds(self) -> float: ...
|
| 127 |
+
# inject Period properties
|
| 128 |
+
@property
|
| 129 |
+
def qyear(self) -> float: ...
|
| 130 |
+
def __eq__(self, other: object) -> bool: ...
|
| 131 |
+
def __ne__(self, other: object) -> bool: ...
|
| 132 |
+
__lt__: _NatComparison
|
| 133 |
+
__le__: _NatComparison
|
| 134 |
+
__gt__: _NatComparison
|
| 135 |
+
__ge__: _NatComparison
|
| 136 |
+
def __sub__(self, other: Self | timedelta | datetime) -> Self: ...
|
| 137 |
+
def __rsub__(self, other: Self | timedelta | datetime) -> Self: ...
|
| 138 |
+
def __add__(self, other: Self | timedelta | datetime) -> Self: ...
|
| 139 |
+
def __radd__(self, other: Self | timedelta | datetime) -> Self: ...
|
| 140 |
+
def __hash__(self) -> int: ...
|
| 141 |
+
def as_unit(self, unit: str, round_ok: bool = ...) -> NaTType: ...
|
lib/python3.12/site-packages/pandas/_libs/tslibs/np_datetime.pyi
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
|
| 3 |
+
from pandas._typing import npt
|
| 4 |
+
|
| 5 |
+
class OutOfBoundsDatetime(ValueError): ...
|
| 6 |
+
class OutOfBoundsTimedelta(ValueError): ...
|
| 7 |
+
|
| 8 |
+
# only exposed for testing
|
| 9 |
+
def py_get_unit_from_dtype(dtype: np.dtype): ...
|
| 10 |
+
def py_td64_to_tdstruct(td64: int, unit: int) -> dict: ...
|
| 11 |
+
def astype_overflowsafe(
|
| 12 |
+
values: np.ndarray,
|
| 13 |
+
dtype: np.dtype,
|
| 14 |
+
copy: bool = ...,
|
| 15 |
+
round_ok: bool = ...,
|
| 16 |
+
is_coerce: bool = ...,
|
| 17 |
+
) -> np.ndarray: ...
|
| 18 |
+
def is_unitless(dtype: np.dtype) -> bool: ...
|
| 19 |
+
def compare_mismatched_resolutions(
|
| 20 |
+
left: np.ndarray, right: np.ndarray, op
|
| 21 |
+
) -> npt.NDArray[np.bool_]: ...
|
| 22 |
+
def add_overflowsafe(
|
| 23 |
+
left: npt.NDArray[np.int64],
|
| 24 |
+
right: npt.NDArray[np.int64],
|
| 25 |
+
) -> npt.NDArray[np.int64]: ...
|
| 26 |
+
def get_supported_dtype(dtype: np.dtype) -> np.dtype: ...
|
| 27 |
+
def is_supported_dtype(dtype: np.dtype) -> bool: ...
|
lib/python3.12/site-packages/pandas/_libs/tslibs/offsets.pyi
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from datetime import (
|
| 2 |
+
datetime,
|
| 3 |
+
time,
|
| 4 |
+
timedelta,
|
| 5 |
+
)
|
| 6 |
+
from typing import (
|
| 7 |
+
Any,
|
| 8 |
+
Collection,
|
| 9 |
+
Literal,
|
| 10 |
+
TypeVar,
|
| 11 |
+
overload,
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
import numpy as np
|
| 15 |
+
|
| 16 |
+
from pandas._libs.tslibs.nattype import NaTType
|
| 17 |
+
from pandas._typing import (
|
| 18 |
+
OffsetCalendar,
|
| 19 |
+
Self,
|
| 20 |
+
npt,
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
from .timedeltas import Timedelta
|
| 24 |
+
|
| 25 |
+
_BaseOffsetT = TypeVar("_BaseOffsetT", bound=BaseOffset)
|
| 26 |
+
_DatetimeT = TypeVar("_DatetimeT", bound=datetime)
|
| 27 |
+
_TimedeltaT = TypeVar("_TimedeltaT", bound=timedelta)
|
| 28 |
+
|
| 29 |
+
_relativedelta_kwds: set[str]
|
| 30 |
+
prefix_mapping: dict[str, type]
|
| 31 |
+
|
| 32 |
+
class ApplyTypeError(TypeError): ...
|
| 33 |
+
|
| 34 |
+
class BaseOffset:
|
| 35 |
+
n: int
|
| 36 |
+
normalize: bool
|
| 37 |
+
def __init__(self, n: int = ..., normalize: bool = ...) -> None: ...
|
| 38 |
+
def __eq__(self, other) -> bool: ...
|
| 39 |
+
def __ne__(self, other) -> bool: ...
|
| 40 |
+
def __hash__(self) -> int: ...
|
| 41 |
+
@property
|
| 42 |
+
def kwds(self) -> dict: ...
|
| 43 |
+
@property
|
| 44 |
+
def base(self) -> BaseOffset: ...
|
| 45 |
+
@overload
|
| 46 |
+
def __add__(self, other: npt.NDArray[np.object_]) -> npt.NDArray[np.object_]: ...
|
| 47 |
+
@overload
|
| 48 |
+
def __add__(self, other: BaseOffset) -> Self: ...
|
| 49 |
+
@overload
|
| 50 |
+
def __add__(self, other: _DatetimeT) -> _DatetimeT: ...
|
| 51 |
+
@overload
|
| 52 |
+
def __add__(self, other: _TimedeltaT) -> _TimedeltaT: ...
|
| 53 |
+
@overload
|
| 54 |
+
def __radd__(self, other: npt.NDArray[np.object_]) -> npt.NDArray[np.object_]: ...
|
| 55 |
+
@overload
|
| 56 |
+
def __radd__(self, other: BaseOffset) -> Self: ...
|
| 57 |
+
@overload
|
| 58 |
+
def __radd__(self, other: _DatetimeT) -> _DatetimeT: ...
|
| 59 |
+
@overload
|
| 60 |
+
def __radd__(self, other: _TimedeltaT) -> _TimedeltaT: ...
|
| 61 |
+
@overload
|
| 62 |
+
def __radd__(self, other: NaTType) -> NaTType: ...
|
| 63 |
+
def __sub__(self, other: BaseOffset) -> Self: ...
|
| 64 |
+
@overload
|
| 65 |
+
def __rsub__(self, other: npt.NDArray[np.object_]) -> npt.NDArray[np.object_]: ...
|
| 66 |
+
@overload
|
| 67 |
+
def __rsub__(self, other: BaseOffset): ...
|
| 68 |
+
@overload
|
| 69 |
+
def __rsub__(self, other: _DatetimeT) -> _DatetimeT: ...
|
| 70 |
+
@overload
|
| 71 |
+
def __rsub__(self, other: _TimedeltaT) -> _TimedeltaT: ...
|
| 72 |
+
@overload
|
| 73 |
+
def __mul__(self, other: np.ndarray) -> np.ndarray: ...
|
| 74 |
+
@overload
|
| 75 |
+
def __mul__(self, other: int): ...
|
| 76 |
+
@overload
|
| 77 |
+
def __rmul__(self, other: np.ndarray) -> np.ndarray: ...
|
| 78 |
+
@overload
|
| 79 |
+
def __rmul__(self, other: int) -> Self: ...
|
| 80 |
+
def __neg__(self) -> Self: ...
|
| 81 |
+
def copy(self) -> Self: ...
|
| 82 |
+
@property
|
| 83 |
+
def name(self) -> str: ...
|
| 84 |
+
@property
|
| 85 |
+
def rule_code(self) -> str: ...
|
| 86 |
+
@property
|
| 87 |
+
def freqstr(self) -> str: ...
|
| 88 |
+
def _apply(self, other): ...
|
| 89 |
+
def _apply_array(self, dtarr: np.ndarray) -> np.ndarray: ...
|
| 90 |
+
def rollback(self, dt: datetime) -> datetime: ...
|
| 91 |
+
def rollforward(self, dt: datetime) -> datetime: ...
|
| 92 |
+
def is_on_offset(self, dt: datetime) -> bool: ...
|
| 93 |
+
def __setstate__(self, state) -> None: ...
|
| 94 |
+
def __getstate__(self): ...
|
| 95 |
+
@property
|
| 96 |
+
def nanos(self) -> int: ...
|
| 97 |
+
def is_anchored(self) -> bool: ...
|
| 98 |
+
|
| 99 |
+
def _get_offset(name: str) -> BaseOffset: ...
|
| 100 |
+
|
| 101 |
+
class SingleConstructorOffset(BaseOffset):
|
| 102 |
+
@classmethod
|
| 103 |
+
def _from_name(cls, suffix: None = ...): ...
|
| 104 |
+
def __reduce__(self): ...
|
| 105 |
+
|
| 106 |
+
@overload
|
| 107 |
+
def to_offset(freq: None, is_period: bool = ...) -> None: ...
|
| 108 |
+
@overload
|
| 109 |
+
def to_offset(freq: _BaseOffsetT, is_period: bool = ...) -> _BaseOffsetT: ...
|
| 110 |
+
@overload
|
| 111 |
+
def to_offset(freq: timedelta | str, is_period: bool = ...) -> BaseOffset: ...
|
| 112 |
+
|
| 113 |
+
class Tick(SingleConstructorOffset):
|
| 114 |
+
_creso: int
|
| 115 |
+
_prefix: str
|
| 116 |
+
def __init__(self, n: int = ..., normalize: bool = ...) -> None: ...
|
| 117 |
+
@property
|
| 118 |
+
def delta(self) -> Timedelta: ...
|
| 119 |
+
@property
|
| 120 |
+
def nanos(self) -> int: ...
|
| 121 |
+
|
| 122 |
+
def delta_to_tick(delta: timedelta) -> Tick: ...
|
| 123 |
+
|
| 124 |
+
class Day(Tick): ...
|
| 125 |
+
class Hour(Tick): ...
|
| 126 |
+
class Minute(Tick): ...
|
| 127 |
+
class Second(Tick): ...
|
| 128 |
+
class Milli(Tick): ...
|
| 129 |
+
class Micro(Tick): ...
|
| 130 |
+
class Nano(Tick): ...
|
| 131 |
+
|
| 132 |
+
class RelativeDeltaOffset(BaseOffset):
|
| 133 |
+
def __init__(self, n: int = ..., normalize: bool = ..., **kwds: Any) -> None: ...
|
| 134 |
+
|
| 135 |
+
class BusinessMixin(SingleConstructorOffset):
|
| 136 |
+
def __init__(
|
| 137 |
+
self, n: int = ..., normalize: bool = ..., offset: timedelta = ...
|
| 138 |
+
) -> None: ...
|
| 139 |
+
|
| 140 |
+
class BusinessDay(BusinessMixin): ...
|
| 141 |
+
|
| 142 |
+
class BusinessHour(BusinessMixin):
|
| 143 |
+
def __init__(
|
| 144 |
+
self,
|
| 145 |
+
n: int = ...,
|
| 146 |
+
normalize: bool = ...,
|
| 147 |
+
start: str | time | Collection[str | time] = ...,
|
| 148 |
+
end: str | time | Collection[str | time] = ...,
|
| 149 |
+
offset: timedelta = ...,
|
| 150 |
+
) -> None: ...
|
| 151 |
+
|
| 152 |
+
class WeekOfMonthMixin(SingleConstructorOffset):
|
| 153 |
+
def __init__(
|
| 154 |
+
self, n: int = ..., normalize: bool = ..., weekday: int = ...
|
| 155 |
+
) -> None: ...
|
| 156 |
+
|
| 157 |
+
class YearOffset(SingleConstructorOffset):
|
| 158 |
+
def __init__(
|
| 159 |
+
self, n: int = ..., normalize: bool = ..., month: int | None = ...
|
| 160 |
+
) -> None: ...
|
| 161 |
+
|
| 162 |
+
class BYearEnd(YearOffset): ...
|
| 163 |
+
class BYearBegin(YearOffset): ...
|
| 164 |
+
class YearEnd(YearOffset): ...
|
| 165 |
+
class YearBegin(YearOffset): ...
|
| 166 |
+
|
| 167 |
+
class QuarterOffset(SingleConstructorOffset):
|
| 168 |
+
def __init__(
|
| 169 |
+
self, n: int = ..., normalize: bool = ..., startingMonth: int | None = ...
|
| 170 |
+
) -> None: ...
|
| 171 |
+
|
| 172 |
+
class BQuarterEnd(QuarterOffset): ...
|
| 173 |
+
class BQuarterBegin(QuarterOffset): ...
|
| 174 |
+
class QuarterEnd(QuarterOffset): ...
|
| 175 |
+
class QuarterBegin(QuarterOffset): ...
|
| 176 |
+
class MonthOffset(SingleConstructorOffset): ...
|
| 177 |
+
class MonthEnd(MonthOffset): ...
|
| 178 |
+
class MonthBegin(MonthOffset): ...
|
| 179 |
+
class BusinessMonthEnd(MonthOffset): ...
|
| 180 |
+
class BusinessMonthBegin(MonthOffset): ...
|
| 181 |
+
|
| 182 |
+
class SemiMonthOffset(SingleConstructorOffset):
|
| 183 |
+
def __init__(
|
| 184 |
+
self, n: int = ..., normalize: bool = ..., day_of_month: int | None = ...
|
| 185 |
+
) -> None: ...
|
| 186 |
+
|
| 187 |
+
class SemiMonthEnd(SemiMonthOffset): ...
|
| 188 |
+
class SemiMonthBegin(SemiMonthOffset): ...
|
| 189 |
+
|
| 190 |
+
class Week(SingleConstructorOffset):
|
| 191 |
+
def __init__(
|
| 192 |
+
self, n: int = ..., normalize: bool = ..., weekday: int | None = ...
|
| 193 |
+
) -> None: ...
|
| 194 |
+
|
| 195 |
+
class WeekOfMonth(WeekOfMonthMixin):
|
| 196 |
+
def __init__(
|
| 197 |
+
self, n: int = ..., normalize: bool = ..., week: int = ..., weekday: int = ...
|
| 198 |
+
) -> None: ...
|
| 199 |
+
|
| 200 |
+
class LastWeekOfMonth(WeekOfMonthMixin): ...
|
| 201 |
+
|
| 202 |
+
class FY5253Mixin(SingleConstructorOffset):
|
| 203 |
+
def __init__(
|
| 204 |
+
self,
|
| 205 |
+
n: int = ...,
|
| 206 |
+
normalize: bool = ...,
|
| 207 |
+
weekday: int = ...,
|
| 208 |
+
startingMonth: int = ...,
|
| 209 |
+
variation: Literal["nearest", "last"] = ...,
|
| 210 |
+
) -> None: ...
|
| 211 |
+
|
| 212 |
+
class FY5253(FY5253Mixin): ...
|
| 213 |
+
|
| 214 |
+
class FY5253Quarter(FY5253Mixin):
|
| 215 |
+
def __init__(
|
| 216 |
+
self,
|
| 217 |
+
n: int = ...,
|
| 218 |
+
normalize: bool = ...,
|
| 219 |
+
weekday: int = ...,
|
| 220 |
+
startingMonth: int = ...,
|
| 221 |
+
qtr_with_extra_week: int = ...,
|
| 222 |
+
variation: Literal["nearest", "last"] = ...,
|
| 223 |
+
) -> None: ...
|
| 224 |
+
|
| 225 |
+
class Easter(SingleConstructorOffset): ...
|
| 226 |
+
|
| 227 |
+
class _CustomBusinessMonth(BusinessMixin):
|
| 228 |
+
def __init__(
|
| 229 |
+
self,
|
| 230 |
+
n: int = ...,
|
| 231 |
+
normalize: bool = ...,
|
| 232 |
+
weekmask: str = ...,
|
| 233 |
+
holidays: list | None = ...,
|
| 234 |
+
calendar: OffsetCalendar | None = ...,
|
| 235 |
+
offset: timedelta = ...,
|
| 236 |
+
) -> None: ...
|
| 237 |
+
|
| 238 |
+
class CustomBusinessDay(BusinessDay):
|
| 239 |
+
def __init__(
|
| 240 |
+
self,
|
| 241 |
+
n: int = ...,
|
| 242 |
+
normalize: bool = ...,
|
| 243 |
+
weekmask: str = ...,
|
| 244 |
+
holidays: list | None = ...,
|
| 245 |
+
calendar: OffsetCalendar | None = ...,
|
| 246 |
+
offset: timedelta = ...,
|
| 247 |
+
) -> None: ...
|
| 248 |
+
|
| 249 |
+
class CustomBusinessHour(BusinessHour):
|
| 250 |
+
def __init__(
|
| 251 |
+
self,
|
| 252 |
+
n: int = ...,
|
| 253 |
+
normalize: bool = ...,
|
| 254 |
+
weekmask: str = ...,
|
| 255 |
+
holidays: list | None = ...,
|
| 256 |
+
calendar: OffsetCalendar | None = ...,
|
| 257 |
+
start: str | time | Collection[str | time] = ...,
|
| 258 |
+
end: str | time | Collection[str | time] = ...,
|
| 259 |
+
offset: timedelta = ...,
|
| 260 |
+
) -> None: ...
|
| 261 |
+
|
| 262 |
+
class CustomBusinessMonthEnd(_CustomBusinessMonth): ...
|
| 263 |
+
class CustomBusinessMonthBegin(_CustomBusinessMonth): ...
|
| 264 |
+
class OffsetMeta(type): ...
|
| 265 |
+
class DateOffset(RelativeDeltaOffset, metaclass=OffsetMeta): ...
|
| 266 |
+
|
| 267 |
+
BDay = BusinessDay
|
| 268 |
+
BMonthEnd = BusinessMonthEnd
|
| 269 |
+
BMonthBegin = BusinessMonthBegin
|
| 270 |
+
CBMonthEnd = CustomBusinessMonthEnd
|
| 271 |
+
CBMonthBegin = CustomBusinessMonthBegin
|
| 272 |
+
CDay = CustomBusinessDay
|
| 273 |
+
|
| 274 |
+
def roll_qtrday(
|
| 275 |
+
other: datetime, n: int, month: int, day_opt: str, modby: int
|
| 276 |
+
) -> int: ...
|
| 277 |
+
|
| 278 |
+
INVALID_FREQ_ERR_MSG: Literal["Invalid frequency: {0}"]
|
| 279 |
+
|
| 280 |
+
def shift_months(
|
| 281 |
+
dtindex: npt.NDArray[np.int64],
|
| 282 |
+
months: int,
|
| 283 |
+
day_opt: str | None = ...,
|
| 284 |
+
reso: int = ...,
|
| 285 |
+
) -> npt.NDArray[np.int64]: ...
|
| 286 |
+
|
| 287 |
+
_offset_map: dict[str, BaseOffset]
|
lib/python3.12/site-packages/pandas/_libs/tslibs/parsing.pyi
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from datetime import datetime
|
| 2 |
+
|
| 3 |
+
import numpy as np
|
| 4 |
+
|
| 5 |
+
from pandas._typing import npt
|
| 6 |
+
|
| 7 |
+
class DateParseError(ValueError): ...
|
| 8 |
+
|
| 9 |
+
def py_parse_datetime_string(
|
| 10 |
+
date_string: str,
|
| 11 |
+
dayfirst: bool = ...,
|
| 12 |
+
yearfirst: bool = ...,
|
| 13 |
+
) -> datetime: ...
|
| 14 |
+
def parse_datetime_string_with_reso(
|
| 15 |
+
date_string: str,
|
| 16 |
+
freq: str | None = ...,
|
| 17 |
+
dayfirst: bool | None = ...,
|
| 18 |
+
yearfirst: bool | None = ...,
|
| 19 |
+
) -> tuple[datetime, str]: ...
|
| 20 |
+
def _does_string_look_like_datetime(py_string: str) -> bool: ...
|
| 21 |
+
def quarter_to_myear(year: int, quarter: int, freq: str) -> tuple[int, int]: ...
|
| 22 |
+
def try_parse_dates(
|
| 23 |
+
values: npt.NDArray[np.object_], # object[:]
|
| 24 |
+
parser,
|
| 25 |
+
) -> npt.NDArray[np.object_]: ...
|
| 26 |
+
def guess_datetime_format(
|
| 27 |
+
dt_str: str,
|
| 28 |
+
dayfirst: bool | None = ...,
|
| 29 |
+
) -> str | None: ...
|
| 30 |
+
def concat_date_cols(
|
| 31 |
+
date_cols: tuple,
|
| 32 |
+
) -> npt.NDArray[np.object_]: ...
|
| 33 |
+
def get_rule_month(source: str) -> str: ...
|
lib/python3.12/site-packages/pandas/_libs/tslibs/period.pyi
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from datetime import timedelta
|
| 2 |
+
from typing import Literal
|
| 3 |
+
|
| 4 |
+
import numpy as np
|
| 5 |
+
|
| 6 |
+
from pandas._libs.tslibs.dtypes import PeriodDtypeBase
|
| 7 |
+
from pandas._libs.tslibs.nattype import NaTType
|
| 8 |
+
from pandas._libs.tslibs.offsets import BaseOffset
|
| 9 |
+
from pandas._libs.tslibs.timestamps import Timestamp
|
| 10 |
+
from pandas._typing import (
|
| 11 |
+
Frequency,
|
| 12 |
+
npt,
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
INVALID_FREQ_ERR_MSG: str
|
| 16 |
+
DIFFERENT_FREQ: str
|
| 17 |
+
|
| 18 |
+
class IncompatibleFrequency(ValueError): ...
|
| 19 |
+
|
| 20 |
+
def periodarr_to_dt64arr(
|
| 21 |
+
periodarr: npt.NDArray[np.int64], # const int64_t[:]
|
| 22 |
+
freq: int,
|
| 23 |
+
) -> npt.NDArray[np.int64]: ...
|
| 24 |
+
def period_asfreq_arr(
|
| 25 |
+
arr: npt.NDArray[np.int64],
|
| 26 |
+
freq1: int,
|
| 27 |
+
freq2: int,
|
| 28 |
+
end: bool,
|
| 29 |
+
) -> npt.NDArray[np.int64]: ...
|
| 30 |
+
def get_period_field_arr(
|
| 31 |
+
field: str,
|
| 32 |
+
arr: npt.NDArray[np.int64], # const int64_t[:]
|
| 33 |
+
freq: int,
|
| 34 |
+
) -> npt.NDArray[np.int64]: ...
|
| 35 |
+
def from_ordinals(
|
| 36 |
+
values: npt.NDArray[np.int64], # const int64_t[:]
|
| 37 |
+
freq: timedelta | BaseOffset | str,
|
| 38 |
+
) -> npt.NDArray[np.int64]: ...
|
| 39 |
+
def extract_ordinals(
|
| 40 |
+
values: npt.NDArray[np.object_],
|
| 41 |
+
freq: Frequency | int,
|
| 42 |
+
) -> npt.NDArray[np.int64]: ...
|
| 43 |
+
def extract_freq(
|
| 44 |
+
values: npt.NDArray[np.object_],
|
| 45 |
+
) -> BaseOffset: ...
|
| 46 |
+
def period_array_strftime(
|
| 47 |
+
values: npt.NDArray[np.int64],
|
| 48 |
+
dtype_code: int,
|
| 49 |
+
na_rep,
|
| 50 |
+
date_format: str | None,
|
| 51 |
+
) -> npt.NDArray[np.object_]: ...
|
| 52 |
+
|
| 53 |
+
# exposed for tests
|
| 54 |
+
def period_asfreq(ordinal: int, freq1: int, freq2: int, end: bool) -> int: ...
|
| 55 |
+
def period_ordinal(
|
| 56 |
+
y: int, m: int, d: int, h: int, min: int, s: int, us: int, ps: int, freq: int
|
| 57 |
+
) -> int: ...
|
| 58 |
+
def freq_to_dtype_code(freq: BaseOffset) -> int: ...
|
| 59 |
+
def validate_end_alias(how: str) -> Literal["E", "S"]: ...
|
| 60 |
+
|
| 61 |
+
class PeriodMixin:
|
| 62 |
+
@property
|
| 63 |
+
def end_time(self) -> Timestamp: ...
|
| 64 |
+
@property
|
| 65 |
+
def start_time(self) -> Timestamp: ...
|
| 66 |
+
def _require_matching_freq(self, other: BaseOffset, base: bool = ...) -> None: ...
|
| 67 |
+
|
| 68 |
+
class Period(PeriodMixin):
|
| 69 |
+
ordinal: int # int64_t
|
| 70 |
+
freq: BaseOffset
|
| 71 |
+
_dtype: PeriodDtypeBase
|
| 72 |
+
|
| 73 |
+
# error: "__new__" must return a class instance (got "Union[Period, NaTType]")
|
| 74 |
+
def __new__( # type: ignore[misc]
|
| 75 |
+
cls,
|
| 76 |
+
value=...,
|
| 77 |
+
freq: int | str | BaseOffset | None = ...,
|
| 78 |
+
ordinal: int | None = ...,
|
| 79 |
+
year: int | None = ...,
|
| 80 |
+
month: int | None = ...,
|
| 81 |
+
quarter: int | None = ...,
|
| 82 |
+
day: int | None = ...,
|
| 83 |
+
hour: int | None = ...,
|
| 84 |
+
minute: int | None = ...,
|
| 85 |
+
second: int | None = ...,
|
| 86 |
+
) -> Period | NaTType: ...
|
| 87 |
+
@classmethod
|
| 88 |
+
def _maybe_convert_freq(cls, freq) -> BaseOffset: ...
|
| 89 |
+
@classmethod
|
| 90 |
+
def _from_ordinal(cls, ordinal: int, freq: BaseOffset) -> Period: ...
|
| 91 |
+
@classmethod
|
| 92 |
+
def now(cls, freq: Frequency) -> Period: ...
|
| 93 |
+
def strftime(self, fmt: str | None) -> str: ...
|
| 94 |
+
def to_timestamp(
|
| 95 |
+
self,
|
| 96 |
+
freq: str | BaseOffset | None = ...,
|
| 97 |
+
how: str = ...,
|
| 98 |
+
) -> Timestamp: ...
|
| 99 |
+
def asfreq(self, freq: str | BaseOffset, how: str = ...) -> Period: ...
|
| 100 |
+
@property
|
| 101 |
+
def freqstr(self) -> str: ...
|
| 102 |
+
@property
|
| 103 |
+
def is_leap_year(self) -> bool: ...
|
| 104 |
+
@property
|
| 105 |
+
def daysinmonth(self) -> int: ...
|
| 106 |
+
@property
|
| 107 |
+
def days_in_month(self) -> int: ...
|
| 108 |
+
@property
|
| 109 |
+
def qyear(self) -> int: ...
|
| 110 |
+
@property
|
| 111 |
+
def quarter(self) -> int: ...
|
| 112 |
+
@property
|
| 113 |
+
def day_of_year(self) -> int: ...
|
| 114 |
+
@property
|
| 115 |
+
def weekday(self) -> int: ...
|
| 116 |
+
@property
|
| 117 |
+
def day_of_week(self) -> int: ...
|
| 118 |
+
@property
|
| 119 |
+
def week(self) -> int: ...
|
| 120 |
+
@property
|
| 121 |
+
def weekofyear(self) -> int: ...
|
| 122 |
+
@property
|
| 123 |
+
def second(self) -> int: ...
|
| 124 |
+
@property
|
| 125 |
+
def minute(self) -> int: ...
|
| 126 |
+
@property
|
| 127 |
+
def hour(self) -> int: ...
|
| 128 |
+
@property
|
| 129 |
+
def day(self) -> int: ...
|
| 130 |
+
@property
|
| 131 |
+
def month(self) -> int: ...
|
| 132 |
+
@property
|
| 133 |
+
def year(self) -> int: ...
|
| 134 |
+
def __sub__(self, other) -> Period | BaseOffset: ...
|
| 135 |
+
def __add__(self, other) -> Period: ...
|
lib/python3.12/site-packages/pandas/_libs/tslibs/strptime.pyi
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
|
| 3 |
+
from pandas._typing import npt
|
| 4 |
+
|
| 5 |
+
def array_strptime(
|
| 6 |
+
values: npt.NDArray[np.object_],
|
| 7 |
+
fmt: str | None,
|
| 8 |
+
exact: bool = ...,
|
| 9 |
+
errors: str = ...,
|
| 10 |
+
utc: bool = ...,
|
| 11 |
+
creso: int = ..., # NPY_DATETIMEUNIT
|
| 12 |
+
) -> tuple[np.ndarray, np.ndarray]: ...
|
| 13 |
+
|
| 14 |
+
# first ndarray is M8[ns], second is object ndarray of tzinfo | None
|
lib/python3.12/site-packages/pandas/_libs/tslibs/timedeltas.pyi
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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,
|
| 14 |
+
Tick,
|
| 15 |
+
)
|
| 16 |
+
from pandas._typing import (
|
| 17 |
+
Frequency,
|
| 18 |
+
Self,
|
| 19 |
+
npt,
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
# This should be kept consistent with the keys in the dict timedelta_abbrevs
|
| 23 |
+
# in pandas/_libs/tslibs/timedeltas.pyx
|
| 24 |
+
UnitChoices: TypeAlias = Literal[
|
| 25 |
+
"Y",
|
| 26 |
+
"y",
|
| 27 |
+
"M",
|
| 28 |
+
"W",
|
| 29 |
+
"w",
|
| 30 |
+
"D",
|
| 31 |
+
"d",
|
| 32 |
+
"days",
|
| 33 |
+
"day",
|
| 34 |
+
"hours",
|
| 35 |
+
"hour",
|
| 36 |
+
"hr",
|
| 37 |
+
"h",
|
| 38 |
+
"m",
|
| 39 |
+
"minute",
|
| 40 |
+
"min",
|
| 41 |
+
"minutes",
|
| 42 |
+
"T",
|
| 43 |
+
"t",
|
| 44 |
+
"s",
|
| 45 |
+
"seconds",
|
| 46 |
+
"sec",
|
| 47 |
+
"second",
|
| 48 |
+
"ms",
|
| 49 |
+
"milliseconds",
|
| 50 |
+
"millisecond",
|
| 51 |
+
"milli",
|
| 52 |
+
"millis",
|
| 53 |
+
"L",
|
| 54 |
+
"l",
|
| 55 |
+
"us",
|
| 56 |
+
"microseconds",
|
| 57 |
+
"microsecond",
|
| 58 |
+
"µs",
|
| 59 |
+
"micro",
|
| 60 |
+
"micros",
|
| 61 |
+
"u",
|
| 62 |
+
"ns",
|
| 63 |
+
"nanoseconds",
|
| 64 |
+
"nano",
|
| 65 |
+
"nanos",
|
| 66 |
+
"nanosecond",
|
| 67 |
+
"n",
|
| 68 |
+
]
|
| 69 |
+
_S = TypeVar("_S", bound=timedelta)
|
| 70 |
+
|
| 71 |
+
def get_unit_for_round(freq, creso: int) -> int: ...
|
| 72 |
+
def disallow_ambiguous_unit(unit: str | None) -> None: ...
|
| 73 |
+
def ints_to_pytimedelta(
|
| 74 |
+
m8values: npt.NDArray[np.timedelta64],
|
| 75 |
+
box: bool = ...,
|
| 76 |
+
) -> npt.NDArray[np.object_]: ...
|
| 77 |
+
def array_to_timedelta64(
|
| 78 |
+
values: npt.NDArray[np.object_],
|
| 79 |
+
unit: str | None = ...,
|
| 80 |
+
errors: str = ...,
|
| 81 |
+
) -> np.ndarray: ... # np.ndarray[m8ns]
|
| 82 |
+
def parse_timedelta_unit(unit: str | None) -> UnitChoices: ...
|
| 83 |
+
def delta_to_nanoseconds(
|
| 84 |
+
delta: np.timedelta64 | timedelta | Tick,
|
| 85 |
+
reso: int = ..., # NPY_DATETIMEUNIT
|
| 86 |
+
round_ok: bool = ...,
|
| 87 |
+
) -> int: ...
|
| 88 |
+
def floordiv_object_array(
|
| 89 |
+
left: np.ndarray, right: npt.NDArray[np.object_]
|
| 90 |
+
) -> np.ndarray: ...
|
| 91 |
+
def truediv_object_array(
|
| 92 |
+
left: np.ndarray, right: npt.NDArray[np.object_]
|
| 93 |
+
) -> np.ndarray: ...
|
| 94 |
+
|
| 95 |
+
class Timedelta(timedelta):
|
| 96 |
+
_creso: int
|
| 97 |
+
min: ClassVar[Timedelta]
|
| 98 |
+
max: ClassVar[Timedelta]
|
| 99 |
+
resolution: ClassVar[Timedelta]
|
| 100 |
+
value: int # np.int64
|
| 101 |
+
_value: int # np.int64
|
| 102 |
+
# error: "__new__" must return a class instance (got "Union[Timestamp, NaTType]")
|
| 103 |
+
def __new__( # type: ignore[misc]
|
| 104 |
+
cls: type[_S],
|
| 105 |
+
value=...,
|
| 106 |
+
unit: str | None = ...,
|
| 107 |
+
**kwargs: float | np.integer | np.floating,
|
| 108 |
+
) -> _S | NaTType: ...
|
| 109 |
+
@classmethod
|
| 110 |
+
def _from_value_and_reso(cls, value: np.int64, reso: int) -> Timedelta: ...
|
| 111 |
+
@property
|
| 112 |
+
def days(self) -> int: ...
|
| 113 |
+
@property
|
| 114 |
+
def seconds(self) -> int: ...
|
| 115 |
+
@property
|
| 116 |
+
def microseconds(self) -> int: ...
|
| 117 |
+
def total_seconds(self) -> float: ...
|
| 118 |
+
def to_pytimedelta(self) -> timedelta: ...
|
| 119 |
+
def to_timedelta64(self) -> np.timedelta64: ...
|
| 120 |
+
@property
|
| 121 |
+
def asm8(self) -> np.timedelta64: ...
|
| 122 |
+
# TODO: round/floor/ceil could return NaT?
|
| 123 |
+
def round(self, freq: Frequency) -> Self: ...
|
| 124 |
+
def floor(self, freq: Frequency) -> Self: ...
|
| 125 |
+
def ceil(self, freq: Frequency) -> Self: ...
|
| 126 |
+
@property
|
| 127 |
+
def resolution_string(self) -> str: ...
|
| 128 |
+
def __add__(self, other: timedelta) -> Timedelta: ...
|
| 129 |
+
def __radd__(self, other: timedelta) -> Timedelta: ...
|
| 130 |
+
def __sub__(self, other: timedelta) -> Timedelta: ...
|
| 131 |
+
def __rsub__(self, other: timedelta) -> Timedelta: ...
|
| 132 |
+
def __neg__(self) -> Timedelta: ...
|
| 133 |
+
def __pos__(self) -> Timedelta: ...
|
| 134 |
+
def __abs__(self) -> Timedelta: ...
|
| 135 |
+
def __mul__(self, other: float) -> Timedelta: ...
|
| 136 |
+
def __rmul__(self, other: float) -> Timedelta: ...
|
| 137 |
+
# error: Signature of "__floordiv__" incompatible with supertype "timedelta"
|
| 138 |
+
@overload # type: ignore[override]
|
| 139 |
+
def __floordiv__(self, other: timedelta) -> int: ...
|
| 140 |
+
@overload
|
| 141 |
+
def __floordiv__(self, other: float) -> Timedelta: ...
|
| 142 |
+
@overload
|
| 143 |
+
def __floordiv__(
|
| 144 |
+
self, other: npt.NDArray[np.timedelta64]
|
| 145 |
+
) -> npt.NDArray[np.intp]: ...
|
| 146 |
+
@overload
|
| 147 |
+
def __floordiv__(
|
| 148 |
+
self, other: npt.NDArray[np.number]
|
| 149 |
+
) -> npt.NDArray[np.timedelta64] | Timedelta: ...
|
| 150 |
+
@overload
|
| 151 |
+
def __rfloordiv__(self, other: timedelta | str) -> int: ...
|
| 152 |
+
@overload
|
| 153 |
+
def __rfloordiv__(self, other: None | NaTType) -> NaTType: ...
|
| 154 |
+
@overload
|
| 155 |
+
def __rfloordiv__(self, other: np.ndarray) -> npt.NDArray[np.timedelta64]: ...
|
| 156 |
+
@overload
|
| 157 |
+
def __truediv__(self, other: timedelta) -> float: ...
|
| 158 |
+
@overload
|
| 159 |
+
def __truediv__(self, other: float) -> Timedelta: ...
|
| 160 |
+
def __mod__(self, other: timedelta) -> Timedelta: ...
|
| 161 |
+
def __divmod__(self, other: timedelta) -> tuple[int, Timedelta]: ...
|
| 162 |
+
def __le__(self, other: timedelta) -> bool: ...
|
| 163 |
+
def __lt__(self, other: timedelta) -> bool: ...
|
| 164 |
+
def __ge__(self, other: timedelta) -> bool: ...
|
| 165 |
+
def __gt__(self, other: timedelta) -> bool: ...
|
| 166 |
+
def __hash__(self) -> int: ...
|
| 167 |
+
def isoformat(self) -> str: ...
|
| 168 |
+
def to_numpy(
|
| 169 |
+
self, dtype: npt.DTypeLike = ..., copy: bool = False
|
| 170 |
+
) -> np.timedelta64: ...
|
| 171 |
+
def view(self, dtype: npt.DTypeLike) -> object: ...
|
| 172 |
+
@property
|
| 173 |
+
def unit(self) -> str: ...
|
| 174 |
+
def as_unit(self, unit: str, round_ok: bool = ...) -> Timedelta: ...
|
lib/python3.12/site-packages/pandas/_libs/tslibs/timestamps.pyi
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from datetime import (
|
| 2 |
+
date as _date,
|
| 3 |
+
datetime,
|
| 4 |
+
time as _time,
|
| 5 |
+
timedelta,
|
| 6 |
+
tzinfo as _tzinfo,
|
| 7 |
+
)
|
| 8 |
+
from time import struct_time
|
| 9 |
+
from typing import (
|
| 10 |
+
ClassVar,
|
| 11 |
+
Literal,
|
| 12 |
+
TypeAlias,
|
| 13 |
+
overload,
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
import numpy as np
|
| 17 |
+
|
| 18 |
+
from pandas._libs.tslibs import (
|
| 19 |
+
BaseOffset,
|
| 20 |
+
NaTType,
|
| 21 |
+
Period,
|
| 22 |
+
Tick,
|
| 23 |
+
Timedelta,
|
| 24 |
+
)
|
| 25 |
+
from pandas._typing import (
|
| 26 |
+
Self,
|
| 27 |
+
TimestampNonexistent,
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
_TimeZones: TypeAlias = str | _tzinfo | None | int
|
| 31 |
+
|
| 32 |
+
def integer_op_not_supported(obj: object) -> TypeError: ...
|
| 33 |
+
|
| 34 |
+
class Timestamp(datetime):
|
| 35 |
+
_creso: int
|
| 36 |
+
min: ClassVar[Timestamp]
|
| 37 |
+
max: ClassVar[Timestamp]
|
| 38 |
+
|
| 39 |
+
resolution: ClassVar[Timedelta]
|
| 40 |
+
_value: int # np.int64
|
| 41 |
+
# error: "__new__" must return a class instance (got "Union[Timestamp, NaTType]")
|
| 42 |
+
def __new__( # type: ignore[misc]
|
| 43 |
+
cls: type[Self],
|
| 44 |
+
ts_input: np.integer | float | str | _date | datetime | np.datetime64 = ...,
|
| 45 |
+
year: int | None = ...,
|
| 46 |
+
month: int | None = ...,
|
| 47 |
+
day: int | None = ...,
|
| 48 |
+
hour: int | None = ...,
|
| 49 |
+
minute: int | None = ...,
|
| 50 |
+
second: int | None = ...,
|
| 51 |
+
microsecond: int | None = ...,
|
| 52 |
+
tzinfo: _tzinfo | None = ...,
|
| 53 |
+
*,
|
| 54 |
+
nanosecond: int | None = ...,
|
| 55 |
+
tz: _TimeZones = ...,
|
| 56 |
+
unit: str | int | None = ...,
|
| 57 |
+
fold: int | None = ...,
|
| 58 |
+
) -> Self | NaTType: ...
|
| 59 |
+
@classmethod
|
| 60 |
+
def _from_value_and_reso(
|
| 61 |
+
cls, value: int, reso: int, tz: _TimeZones
|
| 62 |
+
) -> Timestamp: ...
|
| 63 |
+
@property
|
| 64 |
+
def value(self) -> int: ... # np.int64
|
| 65 |
+
@property
|
| 66 |
+
def year(self) -> int: ...
|
| 67 |
+
@property
|
| 68 |
+
def month(self) -> int: ...
|
| 69 |
+
@property
|
| 70 |
+
def day(self) -> int: ...
|
| 71 |
+
@property
|
| 72 |
+
def hour(self) -> int: ...
|
| 73 |
+
@property
|
| 74 |
+
def minute(self) -> int: ...
|
| 75 |
+
@property
|
| 76 |
+
def second(self) -> int: ...
|
| 77 |
+
@property
|
| 78 |
+
def microsecond(self) -> int: ...
|
| 79 |
+
@property
|
| 80 |
+
def nanosecond(self) -> int: ...
|
| 81 |
+
@property
|
| 82 |
+
def tzinfo(self) -> _tzinfo | None: ...
|
| 83 |
+
@property
|
| 84 |
+
def tz(self) -> _tzinfo | None: ...
|
| 85 |
+
@property
|
| 86 |
+
def fold(self) -> int: ...
|
| 87 |
+
@classmethod
|
| 88 |
+
def fromtimestamp(cls, ts: float, tz: _TimeZones = ...) -> Self: ...
|
| 89 |
+
@classmethod
|
| 90 |
+
def utcfromtimestamp(cls, ts: float) -> Self: ...
|
| 91 |
+
@classmethod
|
| 92 |
+
def today(cls, tz: _TimeZones = ...) -> Self: ...
|
| 93 |
+
@classmethod
|
| 94 |
+
def fromordinal(
|
| 95 |
+
cls,
|
| 96 |
+
ordinal: int,
|
| 97 |
+
tz: _TimeZones = ...,
|
| 98 |
+
) -> Self: ...
|
| 99 |
+
@classmethod
|
| 100 |
+
def now(cls, tz: _TimeZones = ...) -> Self: ...
|
| 101 |
+
@classmethod
|
| 102 |
+
def utcnow(cls) -> Self: ...
|
| 103 |
+
# error: Signature of "combine" incompatible with supertype "datetime"
|
| 104 |
+
@classmethod
|
| 105 |
+
def combine( # type: ignore[override]
|
| 106 |
+
cls, date: _date, time: _time
|
| 107 |
+
) -> datetime: ...
|
| 108 |
+
@classmethod
|
| 109 |
+
def fromisoformat(cls, date_string: str) -> Self: ...
|
| 110 |
+
def strftime(self, format: str) -> str: ...
|
| 111 |
+
def __format__(self, fmt: str) -> str: ...
|
| 112 |
+
def toordinal(self) -> int: ...
|
| 113 |
+
def timetuple(self) -> struct_time: ...
|
| 114 |
+
def timestamp(self) -> float: ...
|
| 115 |
+
def utctimetuple(self) -> struct_time: ...
|
| 116 |
+
def date(self) -> _date: ...
|
| 117 |
+
def time(self) -> _time: ...
|
| 118 |
+
def timetz(self) -> _time: ...
|
| 119 |
+
# LSP violation: nanosecond is not present in datetime.datetime.replace
|
| 120 |
+
# and has positional args following it
|
| 121 |
+
def replace( # type: ignore[override]
|
| 122 |
+
self,
|
| 123 |
+
year: int | None = ...,
|
| 124 |
+
month: int | None = ...,
|
| 125 |
+
day: int | None = ...,
|
| 126 |
+
hour: int | None = ...,
|
| 127 |
+
minute: int | None = ...,
|
| 128 |
+
second: int | None = ...,
|
| 129 |
+
microsecond: int | None = ...,
|
| 130 |
+
nanosecond: int | None = ...,
|
| 131 |
+
tzinfo: _tzinfo | type[object] | None = ...,
|
| 132 |
+
fold: int | None = ...,
|
| 133 |
+
) -> Self: ...
|
| 134 |
+
# LSP violation: datetime.datetime.astimezone has a default value for tz
|
| 135 |
+
def astimezone(self, tz: _TimeZones) -> Self: ... # type: ignore[override]
|
| 136 |
+
def ctime(self) -> str: ...
|
| 137 |
+
def isoformat(self, sep: str = ..., timespec: str = ...) -> str: ...
|
| 138 |
+
@classmethod
|
| 139 |
+
def strptime(
|
| 140 |
+
# Note: strptime is actually disabled and raises NotImplementedError
|
| 141 |
+
cls,
|
| 142 |
+
date_string: str,
|
| 143 |
+
format: str,
|
| 144 |
+
) -> Self: ...
|
| 145 |
+
def utcoffset(self) -> timedelta | None: ...
|
| 146 |
+
def tzname(self) -> str | None: ...
|
| 147 |
+
def dst(self) -> timedelta | None: ...
|
| 148 |
+
def __le__(self, other: datetime) -> bool: ... # type: ignore[override]
|
| 149 |
+
def __lt__(self, other: datetime) -> bool: ... # type: ignore[override]
|
| 150 |
+
def __ge__(self, other: datetime) -> bool: ... # type: ignore[override]
|
| 151 |
+
def __gt__(self, other: datetime) -> bool: ... # type: ignore[override]
|
| 152 |
+
# error: Signature of "__add__" incompatible with supertype "date"/"datetime"
|
| 153 |
+
@overload # type: ignore[override]
|
| 154 |
+
def __add__(self, other: np.ndarray) -> np.ndarray: ...
|
| 155 |
+
@overload
|
| 156 |
+
def __add__(self, other: timedelta | np.timedelta64 | Tick) -> Self: ...
|
| 157 |
+
def __radd__(self, other: timedelta) -> Self: ...
|
| 158 |
+
@overload # type: ignore[override]
|
| 159 |
+
def __sub__(self, other: datetime) -> Timedelta: ...
|
| 160 |
+
@overload
|
| 161 |
+
def __sub__(self, other: timedelta | np.timedelta64 | Tick) -> Self: ...
|
| 162 |
+
def __hash__(self) -> int: ...
|
| 163 |
+
def weekday(self) -> int: ...
|
| 164 |
+
def isoweekday(self) -> int: ...
|
| 165 |
+
# Return type "Tuple[int, int, int]" of "isocalendar" incompatible with return
|
| 166 |
+
# type "_IsoCalendarDate" in supertype "date"
|
| 167 |
+
def isocalendar(self) -> tuple[int, int, int]: ... # type: ignore[override]
|
| 168 |
+
@property
|
| 169 |
+
def is_leap_year(self) -> bool: ...
|
| 170 |
+
@property
|
| 171 |
+
def is_month_start(self) -> bool: ...
|
| 172 |
+
@property
|
| 173 |
+
def is_quarter_start(self) -> bool: ...
|
| 174 |
+
@property
|
| 175 |
+
def is_year_start(self) -> bool: ...
|
| 176 |
+
@property
|
| 177 |
+
def is_month_end(self) -> bool: ...
|
| 178 |
+
@property
|
| 179 |
+
def is_quarter_end(self) -> bool: ...
|
| 180 |
+
@property
|
| 181 |
+
def is_year_end(self) -> bool: ...
|
| 182 |
+
def to_pydatetime(self, warn: bool = ...) -> datetime: ...
|
| 183 |
+
def to_datetime64(self) -> np.datetime64: ...
|
| 184 |
+
def to_period(self, freq: BaseOffset | str | None = None) -> Period: ...
|
| 185 |
+
def to_julian_date(self) -> np.float64: ...
|
| 186 |
+
@property
|
| 187 |
+
def asm8(self) -> np.datetime64: ...
|
| 188 |
+
def tz_convert(self, tz: _TimeZones) -> Self: ...
|
| 189 |
+
# TODO: could return NaT?
|
| 190 |
+
def tz_localize(
|
| 191 |
+
self,
|
| 192 |
+
tz: _TimeZones,
|
| 193 |
+
ambiguous: bool | Literal["raise", "NaT"] = ...,
|
| 194 |
+
nonexistent: TimestampNonexistent = ...,
|
| 195 |
+
) -> Self: ...
|
| 196 |
+
def normalize(self) -> Self: ...
|
| 197 |
+
# TODO: round/floor/ceil could return NaT?
|
| 198 |
+
def round(
|
| 199 |
+
self,
|
| 200 |
+
freq: str,
|
| 201 |
+
ambiguous: bool | Literal["raise", "NaT"] = ...,
|
| 202 |
+
nonexistent: TimestampNonexistent = ...,
|
| 203 |
+
) -> Self: ...
|
| 204 |
+
def floor(
|
| 205 |
+
self,
|
| 206 |
+
freq: str,
|
| 207 |
+
ambiguous: bool | Literal["raise", "NaT"] = ...,
|
| 208 |
+
nonexistent: TimestampNonexistent = ...,
|
| 209 |
+
) -> Self: ...
|
| 210 |
+
def ceil(
|
| 211 |
+
self,
|
| 212 |
+
freq: str,
|
| 213 |
+
ambiguous: bool | Literal["raise", "NaT"] = ...,
|
| 214 |
+
nonexistent: TimestampNonexistent = ...,
|
| 215 |
+
) -> Self: ...
|
| 216 |
+
def day_name(self, locale: str | None = ...) -> str: ...
|
| 217 |
+
def month_name(self, locale: str | None = ...) -> str: ...
|
| 218 |
+
@property
|
| 219 |
+
def day_of_week(self) -> int: ...
|
| 220 |
+
@property
|
| 221 |
+
def dayofweek(self) -> int: ...
|
| 222 |
+
@property
|
| 223 |
+
def day_of_year(self) -> int: ...
|
| 224 |
+
@property
|
| 225 |
+
def dayofyear(self) -> int: ...
|
| 226 |
+
@property
|
| 227 |
+
def quarter(self) -> int: ...
|
| 228 |
+
@property
|
| 229 |
+
def week(self) -> int: ...
|
| 230 |
+
def to_numpy(
|
| 231 |
+
self, dtype: np.dtype | None = ..., copy: bool = ...
|
| 232 |
+
) -> np.datetime64: ...
|
| 233 |
+
@property
|
| 234 |
+
def _date_repr(self) -> str: ...
|
| 235 |
+
@property
|
| 236 |
+
def days_in_month(self) -> int: ...
|
| 237 |
+
@property
|
| 238 |
+
def daysinmonth(self) -> int: ...
|
| 239 |
+
@property
|
| 240 |
+
def unit(self) -> str: ...
|
| 241 |
+
def as_unit(self, unit: str, round_ok: bool = ...) -> Timestamp: ...
|
lib/python3.12/site-packages/pandas/_libs/tslibs/timezones.pyi
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from datetime import (
|
| 2 |
+
datetime,
|
| 3 |
+
tzinfo,
|
| 4 |
+
)
|
| 5 |
+
from typing import Callable
|
| 6 |
+
|
| 7 |
+
import numpy as np
|
| 8 |
+
|
| 9 |
+
# imported from dateutil.tz
|
| 10 |
+
dateutil_gettz: Callable[[str], tzinfo]
|
| 11 |
+
|
| 12 |
+
def tz_standardize(tz: tzinfo) -> tzinfo: ...
|
| 13 |
+
def tz_compare(start: tzinfo | None, end: tzinfo | None) -> bool: ...
|
| 14 |
+
def infer_tzinfo(
|
| 15 |
+
start: datetime | None,
|
| 16 |
+
end: datetime | None,
|
| 17 |
+
) -> tzinfo | None: ...
|
| 18 |
+
def maybe_get_tz(tz: str | int | np.int64 | tzinfo | None) -> tzinfo | None: ...
|
| 19 |
+
def get_timezone(tz: tzinfo) -> tzinfo | str: ...
|
| 20 |
+
def is_utc(tz: tzinfo | None) -> bool: ...
|
| 21 |
+
def is_fixed_offset(tz: tzinfo) -> bool: ...
|
lib/python3.12/site-packages/pandas/_libs/tslibs/tzconversion.pyi
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from datetime import (
|
| 2 |
+
timedelta,
|
| 3 |
+
tzinfo,
|
| 4 |
+
)
|
| 5 |
+
from typing import Iterable
|
| 6 |
+
|
| 7 |
+
import numpy as np
|
| 8 |
+
|
| 9 |
+
from pandas._typing import npt
|
| 10 |
+
|
| 11 |
+
# tz_convert_from_utc_single exposed for testing
|
| 12 |
+
def tz_convert_from_utc_single(
|
| 13 |
+
utc_val: np.int64, tz: tzinfo, creso: int = ...
|
| 14 |
+
) -> np.int64: ...
|
| 15 |
+
def tz_localize_to_utc(
|
| 16 |
+
vals: npt.NDArray[np.int64],
|
| 17 |
+
tz: tzinfo | None,
|
| 18 |
+
ambiguous: str | bool | Iterable[bool] | None = ...,
|
| 19 |
+
nonexistent: str | timedelta | np.timedelta64 | None = ...,
|
| 20 |
+
creso: int = ..., # NPY_DATETIMEUNIT
|
| 21 |
+
) -> npt.NDArray[np.int64]: ...
|
lib/python3.12/site-packages/pandas/_libs/tslibs/vectorized.pyi
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
For cython types that cannot be represented precisely, closest-available
|
| 3 |
+
python equivalents are used, and the precise types kept as adjacent comments.
|
| 4 |
+
"""
|
| 5 |
+
from datetime import tzinfo
|
| 6 |
+
|
| 7 |
+
import numpy as np
|
| 8 |
+
|
| 9 |
+
from pandas._libs.tslibs.dtypes import Resolution
|
| 10 |
+
from pandas._typing import npt
|
| 11 |
+
|
| 12 |
+
def dt64arr_to_periodarr(
|
| 13 |
+
stamps: npt.NDArray[np.int64],
|
| 14 |
+
freq: int,
|
| 15 |
+
tz: tzinfo | None,
|
| 16 |
+
reso: int = ..., # NPY_DATETIMEUNIT
|
| 17 |
+
) -> npt.NDArray[np.int64]: ...
|
| 18 |
+
def is_date_array_normalized(
|
| 19 |
+
stamps: npt.NDArray[np.int64],
|
| 20 |
+
tz: tzinfo | None,
|
| 21 |
+
reso: int, # NPY_DATETIMEUNIT
|
| 22 |
+
) -> bool: ...
|
| 23 |
+
def normalize_i8_timestamps(
|
| 24 |
+
stamps: npt.NDArray[np.int64],
|
| 25 |
+
tz: tzinfo | None,
|
| 26 |
+
reso: int, # NPY_DATETIMEUNIT
|
| 27 |
+
) -> npt.NDArray[np.int64]: ...
|
| 28 |
+
def get_resolution(
|
| 29 |
+
stamps: npt.NDArray[np.int64],
|
| 30 |
+
tz: tzinfo | None = ...,
|
| 31 |
+
reso: int = ..., # NPY_DATETIMEUNIT
|
| 32 |
+
) -> Resolution: ...
|
| 33 |
+
def ints_to_pydatetime(
|
| 34 |
+
stamps: npt.NDArray[np.int64],
|
| 35 |
+
tz: tzinfo | None = ...,
|
| 36 |
+
box: str = ...,
|
| 37 |
+
reso: int = ..., # NPY_DATETIMEUNIT
|
| 38 |
+
) -> npt.NDArray[np.object_]: ...
|
| 39 |
+
def tz_convert_from_utc(
|
| 40 |
+
stamps: npt.NDArray[np.int64],
|
| 41 |
+
tz: tzinfo | None,
|
| 42 |
+
reso: int = ..., # NPY_DATETIMEUNIT
|
| 43 |
+
) -> npt.NDArray[np.int64]: ...
|
lib/python3.12/site-packages/pandas/_libs/window/__init__.py
ADDED
|
File without changes
|
lib/python3.12/site-packages/pandas/_libs/window/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (198 Bytes). View file
|
|
|
lib/python3.12/site-packages/pandas/_libs/window/aggregations.pyi
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import (
|
| 2 |
+
Any,
|
| 3 |
+
Callable,
|
| 4 |
+
Literal,
|
| 5 |
+
)
|
| 6 |
+
|
| 7 |
+
import numpy as np
|
| 8 |
+
|
| 9 |
+
from pandas._typing import (
|
| 10 |
+
WindowingRankType,
|
| 11 |
+
npt,
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
def roll_sum(
|
| 15 |
+
values: np.ndarray, # const float64_t[:]
|
| 16 |
+
start: np.ndarray, # np.ndarray[np.int64]
|
| 17 |
+
end: np.ndarray, # np.ndarray[np.int64]
|
| 18 |
+
minp: int, # int64_t
|
| 19 |
+
) -> np.ndarray: ... # np.ndarray[float]
|
| 20 |
+
def roll_mean(
|
| 21 |
+
values: np.ndarray, # const float64_t[:]
|
| 22 |
+
start: np.ndarray, # np.ndarray[np.int64]
|
| 23 |
+
end: np.ndarray, # np.ndarray[np.int64]
|
| 24 |
+
minp: int, # int64_t
|
| 25 |
+
) -> np.ndarray: ... # np.ndarray[float]
|
| 26 |
+
def roll_var(
|
| 27 |
+
values: np.ndarray, # const float64_t[:]
|
| 28 |
+
start: np.ndarray, # np.ndarray[np.int64]
|
| 29 |
+
end: np.ndarray, # np.ndarray[np.int64]
|
| 30 |
+
minp: int, # int64_t
|
| 31 |
+
ddof: int = ...,
|
| 32 |
+
) -> np.ndarray: ... # np.ndarray[float]
|
| 33 |
+
def roll_skew(
|
| 34 |
+
values: np.ndarray, # np.ndarray[np.float64]
|
| 35 |
+
start: np.ndarray, # np.ndarray[np.int64]
|
| 36 |
+
end: np.ndarray, # np.ndarray[np.int64]
|
| 37 |
+
minp: int, # int64_t
|
| 38 |
+
) -> np.ndarray: ... # np.ndarray[float]
|
| 39 |
+
def roll_kurt(
|
| 40 |
+
values: np.ndarray, # np.ndarray[np.float64]
|
| 41 |
+
start: np.ndarray, # np.ndarray[np.int64]
|
| 42 |
+
end: np.ndarray, # np.ndarray[np.int64]
|
| 43 |
+
minp: int, # int64_t
|
| 44 |
+
) -> np.ndarray: ... # np.ndarray[float]
|
| 45 |
+
def roll_median_c(
|
| 46 |
+
values: np.ndarray, # np.ndarray[np.float64]
|
| 47 |
+
start: np.ndarray, # np.ndarray[np.int64]
|
| 48 |
+
end: np.ndarray, # np.ndarray[np.int64]
|
| 49 |
+
minp: int, # int64_t
|
| 50 |
+
) -> np.ndarray: ... # np.ndarray[float]
|
| 51 |
+
def roll_max(
|
| 52 |
+
values: np.ndarray, # np.ndarray[np.float64]
|
| 53 |
+
start: np.ndarray, # np.ndarray[np.int64]
|
| 54 |
+
end: np.ndarray, # np.ndarray[np.int64]
|
| 55 |
+
minp: int, # int64_t
|
| 56 |
+
) -> np.ndarray: ... # np.ndarray[float]
|
| 57 |
+
def roll_min(
|
| 58 |
+
values: np.ndarray, # np.ndarray[np.float64]
|
| 59 |
+
start: np.ndarray, # np.ndarray[np.int64]
|
| 60 |
+
end: np.ndarray, # np.ndarray[np.int64]
|
| 61 |
+
minp: int, # int64_t
|
| 62 |
+
) -> np.ndarray: ... # np.ndarray[float]
|
| 63 |
+
def roll_quantile(
|
| 64 |
+
values: np.ndarray, # const float64_t[:]
|
| 65 |
+
start: np.ndarray, # np.ndarray[np.int64]
|
| 66 |
+
end: np.ndarray, # np.ndarray[np.int64]
|
| 67 |
+
minp: int, # int64_t
|
| 68 |
+
quantile: float, # float64_t
|
| 69 |
+
interpolation: Literal["linear", "lower", "higher", "nearest", "midpoint"],
|
| 70 |
+
) -> np.ndarray: ... # np.ndarray[float]
|
| 71 |
+
def roll_rank(
|
| 72 |
+
values: np.ndarray,
|
| 73 |
+
start: np.ndarray,
|
| 74 |
+
end: np.ndarray,
|
| 75 |
+
minp: int,
|
| 76 |
+
percentile: bool,
|
| 77 |
+
method: WindowingRankType,
|
| 78 |
+
ascending: bool,
|
| 79 |
+
) -> np.ndarray: ... # np.ndarray[float]
|
| 80 |
+
def roll_apply(
|
| 81 |
+
obj: object,
|
| 82 |
+
start: np.ndarray, # np.ndarray[np.int64]
|
| 83 |
+
end: np.ndarray, # np.ndarray[np.int64]
|
| 84 |
+
minp: int, # int64_t
|
| 85 |
+
function: Callable[..., Any],
|
| 86 |
+
raw: bool,
|
| 87 |
+
args: tuple[Any, ...],
|
| 88 |
+
kwargs: dict[str, Any],
|
| 89 |
+
) -> npt.NDArray[np.float64]: ...
|
| 90 |
+
def roll_weighted_sum(
|
| 91 |
+
values: np.ndarray, # const float64_t[:]
|
| 92 |
+
weights: np.ndarray, # const float64_t[:]
|
| 93 |
+
minp: int,
|
| 94 |
+
) -> np.ndarray: ... # np.ndarray[np.float64]
|
| 95 |
+
def roll_weighted_mean(
|
| 96 |
+
values: np.ndarray, # const float64_t[:]
|
| 97 |
+
weights: np.ndarray, # const float64_t[:]
|
| 98 |
+
minp: int,
|
| 99 |
+
) -> np.ndarray: ... # np.ndarray[np.float64]
|
| 100 |
+
def roll_weighted_var(
|
| 101 |
+
values: np.ndarray, # const float64_t[:]
|
| 102 |
+
weights: np.ndarray, # const float64_t[:]
|
| 103 |
+
minp: int, # int64_t
|
| 104 |
+
ddof: int, # unsigned int
|
| 105 |
+
) -> np.ndarray: ... # np.ndarray[np.float64]
|
| 106 |
+
def ewm(
|
| 107 |
+
vals: np.ndarray, # const float64_t[:]
|
| 108 |
+
start: np.ndarray, # const int64_t[:]
|
| 109 |
+
end: np.ndarray, # const int64_t[:]
|
| 110 |
+
minp: int,
|
| 111 |
+
com: float, # float64_t
|
| 112 |
+
adjust: bool,
|
| 113 |
+
ignore_na: bool,
|
| 114 |
+
deltas: np.ndarray | None = None, # const float64_t[:]
|
| 115 |
+
normalize: bool = True,
|
| 116 |
+
) -> np.ndarray: ... # np.ndarray[np.float64]
|
| 117 |
+
def ewmcov(
|
| 118 |
+
input_x: np.ndarray, # const float64_t[:]
|
| 119 |
+
start: np.ndarray, # const int64_t[:]
|
| 120 |
+
end: np.ndarray, # const int64_t[:]
|
| 121 |
+
minp: int,
|
| 122 |
+
input_y: np.ndarray, # const float64_t[:]
|
| 123 |
+
com: float, # float64_t
|
| 124 |
+
adjust: bool,
|
| 125 |
+
ignore_na: bool,
|
| 126 |
+
bias: bool,
|
| 127 |
+
) -> np.ndarray: ... # np.ndarray[np.float64]
|
lib/python3.12/site-packages/pandas/_libs/window/indexers.pyi
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
|
| 3 |
+
from pandas._typing import npt
|
| 4 |
+
|
| 5 |
+
def calculate_variable_window_bounds(
|
| 6 |
+
num_values: int, # int64_t
|
| 7 |
+
window_size: int, # int64_t
|
| 8 |
+
min_periods,
|
| 9 |
+
center: bool,
|
| 10 |
+
closed: str | None,
|
| 11 |
+
index: np.ndarray, # const int64_t[:]
|
| 12 |
+
) -> tuple[npt.NDArray[np.int64], npt.NDArray[np.int64]]: ...
|
lib/python3.12/site-packages/pandas/api/__init__.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
""" public toolkit API """
|
| 2 |
+
from pandas.api import (
|
| 3 |
+
extensions,
|
| 4 |
+
indexers,
|
| 5 |
+
interchange,
|
| 6 |
+
types,
|
| 7 |
+
typing,
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
__all__ = [
|
| 11 |
+
"interchange",
|
| 12 |
+
"extensions",
|
| 13 |
+
"indexers",
|
| 14 |
+
"types",
|
| 15 |
+
"typing",
|
| 16 |
+
]
|
lib/python3.12/site-packages/pandas/api/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (407 Bytes). View file
|
|
|
lib/python3.12/site-packages/pandas/api/extensions/__init__.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Public API for extending pandas objects.
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
from pandas._libs.lib import no_default
|
| 6 |
+
|
| 7 |
+
from pandas.core.dtypes.base import (
|
| 8 |
+
ExtensionDtype,
|
| 9 |
+
register_extension_dtype,
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
from pandas.core.accessor import (
|
| 13 |
+
register_dataframe_accessor,
|
| 14 |
+
register_index_accessor,
|
| 15 |
+
register_series_accessor,
|
| 16 |
+
)
|
| 17 |
+
from pandas.core.algorithms import take
|
| 18 |
+
from pandas.core.arrays import (
|
| 19 |
+
ExtensionArray,
|
| 20 |
+
ExtensionScalarOpsMixin,
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
__all__ = [
|
| 24 |
+
"no_default",
|
| 25 |
+
"ExtensionDtype",
|
| 26 |
+
"register_extension_dtype",
|
| 27 |
+
"register_dataframe_accessor",
|
| 28 |
+
"register_index_accessor",
|
| 29 |
+
"register_series_accessor",
|
| 30 |
+
"take",
|
| 31 |
+
"ExtensionArray",
|
| 32 |
+
"ExtensionScalarOpsMixin",
|
| 33 |
+
]
|
lib/python3.12/site-packages/pandas/api/extensions/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (786 Bytes). View file
|
|
|
lib/python3.12/site-packages/pandas/api/indexers/__init__.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Public API for Rolling Window Indexers.
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
from pandas.core.indexers import check_array_indexer
|
| 6 |
+
from pandas.core.indexers.objects import (
|
| 7 |
+
BaseIndexer,
|
| 8 |
+
FixedForwardWindowIndexer,
|
| 9 |
+
VariableOffsetWindowIndexer,
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
__all__ = [
|
| 13 |
+
"check_array_indexer",
|
| 14 |
+
"BaseIndexer",
|
| 15 |
+
"FixedForwardWindowIndexer",
|
| 16 |
+
"VariableOffsetWindowIndexer",
|
| 17 |
+
]
|
lib/python3.12/site-packages/pandas/api/indexers/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (520 Bytes). View file
|
|
|
lib/python3.12/site-packages/pandas/api/interchange/__init__.py
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Public API for DataFrame interchange protocol.
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
from pandas.core.interchange.dataframe_protocol import DataFrame
|
| 6 |
+
from pandas.core.interchange.from_dataframe import from_dataframe
|
| 7 |
+
|
| 8 |
+
__all__ = ["from_dataframe", "DataFrame"]
|
lib/python3.12/site-packages/pandas/api/interchange/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (466 Bytes). View file
|
|
|
lib/python3.12/site-packages/pandas/api/types/__init__.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Public toolkit API.
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
from pandas._libs.lib import infer_dtype
|
| 6 |
+
|
| 7 |
+
from pandas.core.dtypes.api import * # noqa: F403
|
| 8 |
+
from pandas.core.dtypes.concat import union_categoricals
|
| 9 |
+
from pandas.core.dtypes.dtypes import (
|
| 10 |
+
CategoricalDtype,
|
| 11 |
+
DatetimeTZDtype,
|
| 12 |
+
IntervalDtype,
|
| 13 |
+
PeriodDtype,
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
__all__ = [
|
| 17 |
+
"infer_dtype",
|
| 18 |
+
"union_categoricals",
|
| 19 |
+
"CategoricalDtype",
|
| 20 |
+
"DatetimeTZDtype",
|
| 21 |
+
"IntervalDtype",
|
| 22 |
+
"PeriodDtype",
|
| 23 |
+
]
|
lib/python3.12/site-packages/pandas/api/types/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (606 Bytes). View file
|
|
|
lib/python3.12/site-packages/pandas/api/typing/__init__.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Public API classes that store intermediate results useful for type-hinting.
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
from pandas._libs import NaTType
|
| 6 |
+
from pandas._libs.missing import NAType
|
| 7 |
+
|
| 8 |
+
from pandas.core.groupby import (
|
| 9 |
+
DataFrameGroupBy,
|
| 10 |
+
SeriesGroupBy,
|
| 11 |
+
)
|
| 12 |
+
from pandas.core.resample import (
|
| 13 |
+
DatetimeIndexResamplerGroupby,
|
| 14 |
+
PeriodIndexResamplerGroupby,
|
| 15 |
+
Resampler,
|
| 16 |
+
TimedeltaIndexResamplerGroupby,
|
| 17 |
+
TimeGrouper,
|
| 18 |
+
)
|
| 19 |
+
from pandas.core.window import (
|
| 20 |
+
Expanding,
|
| 21 |
+
ExpandingGroupby,
|
| 22 |
+
ExponentialMovingWindow,
|
| 23 |
+
ExponentialMovingWindowGroupby,
|
| 24 |
+
Rolling,
|
| 25 |
+
RollingGroupby,
|
| 26 |
+
Window,
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
# TODO: Can't import Styler without importing jinja2
|
| 30 |
+
# from pandas.io.formats.style import Styler
|
| 31 |
+
from pandas.io.json._json import JsonReader
|
| 32 |
+
from pandas.io.stata import StataReader
|
| 33 |
+
|
| 34 |
+
__all__ = [
|
| 35 |
+
"DataFrameGroupBy",
|
| 36 |
+
"DatetimeIndexResamplerGroupby",
|
| 37 |
+
"Expanding",
|
| 38 |
+
"ExpandingGroupby",
|
| 39 |
+
"ExponentialMovingWindow",
|
| 40 |
+
"ExponentialMovingWindowGroupby",
|
| 41 |
+
"JsonReader",
|
| 42 |
+
"NaTType",
|
| 43 |
+
"NAType",
|
| 44 |
+
"PeriodIndexResamplerGroupby",
|
| 45 |
+
"Resampler",
|
| 46 |
+
"Rolling",
|
| 47 |
+
"RollingGroupby",
|
| 48 |
+
"SeriesGroupBy",
|
| 49 |
+
"StataReader",
|
| 50 |
+
# See TODO above
|
| 51 |
+
# "Styler",
|
| 52 |
+
"TimedeltaIndexResamplerGroupby",
|
| 53 |
+
"TimeGrouper",
|
| 54 |
+
"Window",
|
| 55 |
+
]
|
lib/python3.12/site-packages/pandas/api/typing/__pycache__/__init__.cpython-312.pyc
ADDED
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
compat
|
| 3 |
+
======
|
| 4 |
+
|
| 5 |
+
Cross-compatible functions for different versions of Python.
|
| 6 |
+
|
| 7 |
+
Other items:
|
| 8 |
+
* platform checker
|
| 9 |
+
"""
|
| 10 |
+
from __future__ import annotations
|
| 11 |
+
|
| 12 |
+
import os
|
| 13 |
+
import platform
|
| 14 |
+
import sys
|
| 15 |
+
from typing import TYPE_CHECKING
|
| 16 |
+
|
| 17 |
+
from pandas.compat._constants import (
|
| 18 |
+
IS64,
|
| 19 |
+
ISMUSL,
|
| 20 |
+
PY310,
|
| 21 |
+
PY311,
|
| 22 |
+
PY312,
|
| 23 |
+
PYPY,
|
| 24 |
+
)
|
| 25 |
+
import pandas.compat.compressors
|
| 26 |
+
from pandas.compat.numpy import is_numpy_dev
|
| 27 |
+
from pandas.compat.pyarrow import (
|
| 28 |
+
pa_version_under10p1,
|
| 29 |
+
pa_version_under11p0,
|
| 30 |
+
pa_version_under13p0,
|
| 31 |
+
pa_version_under14p0,
|
| 32 |
+
pa_version_under14p1,
|
| 33 |
+
pa_version_under16p0,
|
| 34 |
+
pa_version_under17p0,
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
if TYPE_CHECKING:
|
| 38 |
+
from pandas._typing import F
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def set_function_name(f: F, name: str, cls: type) -> F:
|
| 42 |
+
"""
|
| 43 |
+
Bind the name/qualname attributes of the function.
|
| 44 |
+
"""
|
| 45 |
+
f.__name__ = name
|
| 46 |
+
f.__qualname__ = f"{cls.__name__}.{name}"
|
| 47 |
+
f.__module__ = cls.__module__
|
| 48 |
+
return f
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def is_platform_little_endian() -> bool:
|
| 52 |
+
"""
|
| 53 |
+
Checking if the running platform is little endian.
|
| 54 |
+
|
| 55 |
+
Returns
|
| 56 |
+
-------
|
| 57 |
+
bool
|
| 58 |
+
True if the running platform is little endian.
|
| 59 |
+
"""
|
| 60 |
+
return sys.byteorder == "little"
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def is_platform_windows() -> bool:
|
| 64 |
+
"""
|
| 65 |
+
Checking if the running platform is windows.
|
| 66 |
+
|
| 67 |
+
Returns
|
| 68 |
+
-------
|
| 69 |
+
bool
|
| 70 |
+
True if the running platform is windows.
|
| 71 |
+
"""
|
| 72 |
+
return sys.platform in ["win32", "cygwin"]
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def is_platform_linux() -> bool:
|
| 76 |
+
"""
|
| 77 |
+
Checking if the running platform is linux.
|
| 78 |
+
|
| 79 |
+
Returns
|
| 80 |
+
-------
|
| 81 |
+
bool
|
| 82 |
+
True if the running platform is linux.
|
| 83 |
+
"""
|
| 84 |
+
return sys.platform == "linux"
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
def is_platform_mac() -> bool:
|
| 88 |
+
"""
|
| 89 |
+
Checking if the running platform is mac.
|
| 90 |
+
|
| 91 |
+
Returns
|
| 92 |
+
-------
|
| 93 |
+
bool
|
| 94 |
+
True if the running platform is mac.
|
| 95 |
+
"""
|
| 96 |
+
return sys.platform == "darwin"
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
def is_platform_arm() -> bool:
|
| 100 |
+
"""
|
| 101 |
+
Checking if the running platform use ARM architecture.
|
| 102 |
+
|
| 103 |
+
Returns
|
| 104 |
+
-------
|
| 105 |
+
bool
|
| 106 |
+
True if the running platform uses ARM architecture.
|
| 107 |
+
"""
|
| 108 |
+
return platform.machine() in ("arm64", "aarch64") or platform.machine().startswith(
|
| 109 |
+
"armv"
|
| 110 |
+
)
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
def is_platform_power() -> bool:
|
| 114 |
+
"""
|
| 115 |
+
Checking if the running platform use Power architecture.
|
| 116 |
+
|
| 117 |
+
Returns
|
| 118 |
+
-------
|
| 119 |
+
bool
|
| 120 |
+
True if the running platform uses ARM architecture.
|
| 121 |
+
"""
|
| 122 |
+
return platform.machine() in ("ppc64", "ppc64le")
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
def is_ci_environment() -> bool:
|
| 126 |
+
"""
|
| 127 |
+
Checking if running in a continuous integration environment by checking
|
| 128 |
+
the PANDAS_CI environment variable.
|
| 129 |
+
|
| 130 |
+
Returns
|
| 131 |
+
-------
|
| 132 |
+
bool
|
| 133 |
+
True if the running in a continuous integration environment.
|
| 134 |
+
"""
|
| 135 |
+
return os.environ.get("PANDAS_CI", "0") == "1"
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
def get_lzma_file() -> type[pandas.compat.compressors.LZMAFile]:
|
| 139 |
+
"""
|
| 140 |
+
Importing the `LZMAFile` class from the `lzma` module.
|
| 141 |
+
|
| 142 |
+
Returns
|
| 143 |
+
-------
|
| 144 |
+
class
|
| 145 |
+
The `LZMAFile` class from the `lzma` module.
|
| 146 |
+
|
| 147 |
+
Raises
|
| 148 |
+
------
|
| 149 |
+
RuntimeError
|
| 150 |
+
If the `lzma` module was not imported correctly, or didn't exist.
|
| 151 |
+
"""
|
| 152 |
+
if not pandas.compat.compressors.has_lzma:
|
| 153 |
+
raise RuntimeError(
|
| 154 |
+
"lzma module not available. "
|
| 155 |
+
"A Python re-install with the proper dependencies, "
|
| 156 |
+
"might be required to solve this issue."
|
| 157 |
+
)
|
| 158 |
+
return pandas.compat.compressors.LZMAFile
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
def get_bz2_file() -> type[pandas.compat.compressors.BZ2File]:
|
| 162 |
+
"""
|
| 163 |
+
Importing the `BZ2File` class from the `bz2` module.
|
| 164 |
+
|
| 165 |
+
Returns
|
| 166 |
+
-------
|
| 167 |
+
class
|
| 168 |
+
The `BZ2File` class from the `bz2` module.
|
| 169 |
+
|
| 170 |
+
Raises
|
| 171 |
+
------
|
| 172 |
+
RuntimeError
|
| 173 |
+
If the `bz2` module was not imported correctly, or didn't exist.
|
| 174 |
+
"""
|
| 175 |
+
if not pandas.compat.compressors.has_bz2:
|
| 176 |
+
raise RuntimeError(
|
| 177 |
+
"bz2 module not available. "
|
| 178 |
+
"A Python re-install with the proper dependencies, "
|
| 179 |
+
"might be required to solve this issue."
|
| 180 |
+
)
|
| 181 |
+
return pandas.compat.compressors.BZ2File
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
__all__ = [
|
| 185 |
+
"is_numpy_dev",
|
| 186 |
+
"pa_version_under10p1",
|
| 187 |
+
"pa_version_under11p0",
|
| 188 |
+
"pa_version_under13p0",
|
| 189 |
+
"pa_version_under14p0",
|
| 190 |
+
"pa_version_under14p1",
|
| 191 |
+
"pa_version_under16p0",
|
| 192 |
+
"pa_version_under17p0",
|
| 193 |
+
"IS64",
|
| 194 |
+
"ISMUSL",
|
| 195 |
+
"PY310",
|
| 196 |
+
"PY311",
|
| 197 |
+
"PY312",
|
| 198 |
+
"PYPY",
|
| 199 |
+
]
|
lib/python3.12/site-packages/pandas/compat/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (5.76 kB). View file
|
|
|
lib/python3.12/site-packages/pandas/compat/__pycache__/_constants.cpython-312.pyc
ADDED
|
Binary file (991 Bytes). View file
|
|
|
lib/python3.12/site-packages/pandas/compat/__pycache__/_optional.cpython-312.pyc
ADDED
|
Binary file (5.45 kB). View file
|
|
|
lib/python3.12/site-packages/pandas/compat/__pycache__/compressors.cpython-312.pyc
ADDED
|
Binary file (2.32 kB). View file
|
|
|