godlykmathews commited on
Commit
89c2de7
·
verified ·
1 Parent(s): 886c6cd

Upload folder using huggingface_hub (part 9)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +12 -0
  2. venv/lib/python3.14/site-packages/pandas/_libs/tslibs/np_datetime.cpython-314-darwin.so +3 -0
  3. venv/lib/python3.14/site-packages/pandas/_libs/tslibs/np_datetime.pyi +37 -0
  4. venv/lib/python3.14/site-packages/pandas/_libs/tslibs/offsets.cpython-314-darwin.so +3 -0
  5. venv/lib/python3.14/site-packages/pandas/_libs/tslibs/offsets.pyi +346 -0
  6. venv/lib/python3.14/site-packages/pandas/_libs/tslibs/parsing.cpython-314-darwin.so +3 -0
  7. venv/lib/python3.14/site-packages/pandas/_libs/tslibs/parsing.pyi +33 -0
  8. venv/lib/python3.14/site-packages/pandas/_libs/tslibs/period.cpython-314-darwin.so +3 -0
  9. venv/lib/python3.14/site-packages/pandas/_libs/tslibs/period.pyi +146 -0
  10. venv/lib/python3.14/site-packages/pandas/_libs/tslibs/strptime.cpython-314-darwin.so +3 -0
  11. venv/lib/python3.14/site-packages/pandas/_libs/tslibs/strptime.pyi +15 -0
  12. venv/lib/python3.14/site-packages/pandas/_libs/tslibs/timedeltas.cpython-314-darwin.so +3 -0
  13. venv/lib/python3.14/site-packages/pandas/_libs/tslibs/timedeltas.pyi +170 -0
  14. venv/lib/python3.14/site-packages/pandas/_libs/tslibs/timestamps.cpython-314-darwin.so +3 -0
  15. venv/lib/python3.14/site-packages/pandas/_libs/tslibs/timestamps.pyi +284 -0
  16. venv/lib/python3.14/site-packages/pandas/_libs/tslibs/timezones.cpython-314-darwin.so +3 -0
  17. venv/lib/python3.14/site-packages/pandas/_libs/tslibs/timezones.pyi +21 -0
  18. venv/lib/python3.14/site-packages/pandas/_libs/tslibs/tzconversion.cpython-314-darwin.so +3 -0
  19. venv/lib/python3.14/site-packages/pandas/_libs/tslibs/tzconversion.pyi +21 -0
  20. venv/lib/python3.14/site-packages/pandas/_libs/tslibs/vectorized.cpython-314-darwin.so +3 -0
  21. venv/lib/python3.14/site-packages/pandas/_libs/tslibs/vectorized.pyi +41 -0
  22. venv/lib/python3.14/site-packages/pandas/_libs/window/__init__.py +0 -0
  23. venv/lib/python3.14/site-packages/pandas/_libs/window/aggregations.cpython-314-darwin.so +3 -0
  24. venv/lib/python3.14/site-packages/pandas/_libs/window/aggregations.pyi +160 -0
  25. venv/lib/python3.14/site-packages/pandas/_libs/window/indexers.cpython-314-darwin.so +0 -0
  26. venv/lib/python3.14/site-packages/pandas/_libs/window/indexers.pyi +12 -0
  27. venv/lib/python3.14/site-packages/pandas/_libs/writers.cpython-314-darwin.so +3 -0
  28. venv/lib/python3.14/site-packages/pandas/_libs/writers.pyi +20 -0
  29. venv/lib/python3.14/site-packages/pandas/_testing/__init__.py +679 -0
  30. venv/lib/python3.14/site-packages/pandas/_testing/_io.py +133 -0
  31. venv/lib/python3.14/site-packages/pandas/_testing/_warnings.py +283 -0
  32. venv/lib/python3.14/site-packages/pandas/_testing/asserters.py +1749 -0
  33. venv/lib/python3.14/site-packages/pandas/_testing/compat.py +32 -0
  34. venv/lib/python3.14/site-packages/pandas/_testing/contexts.py +159 -0
  35. venv/lib/python3.14/site-packages/pandas/_typing.py +575 -0
  36. venv/lib/python3.14/site-packages/pandas/_version_meson.py +2 -0
  37. venv/lib/python3.14/site-packages/pandas/api/__init__.py +21 -0
  38. venv/lib/python3.14/site-packages/pandas/api/executors/__init__.py +7 -0
  39. venv/lib/python3.14/site-packages/pandas/api/extensions/__init__.py +33 -0
  40. venv/lib/python3.14/site-packages/pandas/api/indexers/__init__.py +17 -0
  41. venv/lib/python3.14/site-packages/pandas/api/interchange/__init__.py +8 -0
  42. venv/lib/python3.14/site-packages/pandas/api/internals.py +61 -0
  43. venv/lib/python3.14/site-packages/pandas/api/types/__init__.py +23 -0
  44. venv/lib/python3.14/site-packages/pandas/api/typing/__init__.py +104 -0
  45. venv/lib/python3.14/site-packages/pandas/api/typing/aliases.py +145 -0
  46. venv/lib/python3.14/site-packages/pandas/arrays/__init__.py +37 -0
  47. venv/lib/python3.14/site-packages/pandas/compat/__init__.py +167 -0
  48. venv/lib/python3.14/site-packages/pandas/compat/_constants.py +39 -0
  49. venv/lib/python3.14/site-packages/pandas/compat/_cpu.py +101 -0
  50. venv/lib/python3.14/site-packages/pandas/compat/_optional.py +191 -0
.gitattributes CHANGED
@@ -98,3 +98,15 @@ venv/lib/python3.14/site-packages/pandas/_libs/tslibs/conversion.cpython-314-dar
98
  venv/lib/python3.14/site-packages/pandas/_libs/tslibs/dtypes.cpython-314-darwin.so filter=lfs diff=lfs merge=lfs -text
99
  venv/lib/python3.14/site-packages/pandas/_libs/tslibs/fields.cpython-314-darwin.so filter=lfs diff=lfs merge=lfs -text
100
  venv/lib/python3.14/site-packages/pandas/_libs/tslibs/nattype.cpython-314-darwin.so filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  venv/lib/python3.14/site-packages/pandas/_libs/tslibs/dtypes.cpython-314-darwin.so filter=lfs diff=lfs merge=lfs -text
99
  venv/lib/python3.14/site-packages/pandas/_libs/tslibs/fields.cpython-314-darwin.so filter=lfs diff=lfs merge=lfs -text
100
  venv/lib/python3.14/site-packages/pandas/_libs/tslibs/nattype.cpython-314-darwin.so filter=lfs diff=lfs merge=lfs -text
101
+ venv/lib/python3.14/site-packages/pandas/_libs/tslibs/np_datetime.cpython-314-darwin.so filter=lfs diff=lfs merge=lfs -text
102
+ venv/lib/python3.14/site-packages/pandas/_libs/tslibs/offsets.cpython-314-darwin.so filter=lfs diff=lfs merge=lfs -text
103
+ venv/lib/python3.14/site-packages/pandas/_libs/tslibs/parsing.cpython-314-darwin.so filter=lfs diff=lfs merge=lfs -text
104
+ venv/lib/python3.14/site-packages/pandas/_libs/tslibs/period.cpython-314-darwin.so filter=lfs diff=lfs merge=lfs -text
105
+ venv/lib/python3.14/site-packages/pandas/_libs/tslibs/strptime.cpython-314-darwin.so filter=lfs diff=lfs merge=lfs -text
106
+ venv/lib/python3.14/site-packages/pandas/_libs/tslibs/timedeltas.cpython-314-darwin.so filter=lfs diff=lfs merge=lfs -text
107
+ venv/lib/python3.14/site-packages/pandas/_libs/tslibs/timestamps.cpython-314-darwin.so filter=lfs diff=lfs merge=lfs -text
108
+ venv/lib/python3.14/site-packages/pandas/_libs/tslibs/timezones.cpython-314-darwin.so filter=lfs diff=lfs merge=lfs -text
109
+ venv/lib/python3.14/site-packages/pandas/_libs/tslibs/tzconversion.cpython-314-darwin.so filter=lfs diff=lfs merge=lfs -text
110
+ venv/lib/python3.14/site-packages/pandas/_libs/tslibs/vectorized.cpython-314-darwin.so filter=lfs diff=lfs merge=lfs -text
111
+ venv/lib/python3.14/site-packages/pandas/_libs/window/aggregations.cpython-314-darwin.so filter=lfs diff=lfs merge=lfs -text
112
+ venv/lib/python3.14/site-packages/pandas/_libs/writers.cpython-314-darwin.so filter=lfs diff=lfs merge=lfs -text
venv/lib/python3.14/site-packages/pandas/_libs/tslibs/np_datetime.cpython-314-darwin.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a634b4217e8938d4d7b16662842b5cf269ea32b4484e377d0526708820088e32
3
+ size 177888
venv/lib/python3.14/site-packages/pandas/_libs/tslibs/np_datetime.pyi ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from collections.abc import Callable
2
+ from typing import Any
3
+
4
+ import numpy as np
5
+
6
+ from pandas._typing import npt
7
+
8
+ class OutOfBoundsDatetime(ValueError): ...
9
+ class OutOfBoundsTimedelta(ValueError): ...
10
+
11
+ # only exposed for testing
12
+ def py_get_unit_from_dtype(dtype: np.dtype) -> int: ...
13
+ def py_td64_to_tdstruct(td64: int, unit: int) -> dict[str, int]: ...
14
+ def astype_overflowsafe(
15
+ values: np.ndarray,
16
+ dtype: np.dtype,
17
+ copy: bool = ...,
18
+ round_ok: bool = ...,
19
+ is_coerce: bool = ...,
20
+ ) -> np.ndarray: ...
21
+ def is_unitless(dtype: np.dtype) -> bool: ...
22
+ def compare_mismatched_resolutions(
23
+ left: npt.NDArray[np.datetime64] | npt.NDArray[np.timedelta64],
24
+ right: npt.NDArray[np.datetime64] | npt.NDArray[np.timedelta64],
25
+ op: Callable[[Any, Any], bool],
26
+ ) -> npt.NDArray[np.bool_]: ...
27
+ def add_overflowsafe(
28
+ left: npt.NDArray[np.int64],
29
+ right: npt.NDArray[np.int64],
30
+ sentinel_ok: bool = ...,
31
+ ) -> npt.NDArray[np.int64]: ...
32
+ def mul_overflowsafe(
33
+ left: npt.NDArray[np.int64],
34
+ right: npt.NDArray[np.int64],
35
+ ) -> npt.NDArray[np.int64]: ...
36
+ def get_supported_dtype(dtype: np.dtype) -> np.dtype: ...
37
+ def is_supported_dtype(dtype: np.dtype) -> bool: ...
venv/lib/python3.14/site-packages/pandas/_libs/tslibs/offsets.cpython-314-darwin.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fd2f6db6552a395c1352aabf69c36c40259601f90e7874cf72b886ae6beb4b9e
3
+ size 1190192
venv/lib/python3.14/site-packages/pandas/_libs/tslibs/offsets.pyi ADDED
@@ -0,0 +1,346 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from collections.abc import Collection
2
+ from datetime import (
3
+ datetime,
4
+ time,
5
+ timedelta,
6
+ )
7
+ from typing import (
8
+ Any,
9
+ Literal,
10
+ Self,
11
+ TypeVar,
12
+ overload,
13
+ )
14
+
15
+ import numpy as np
16
+
17
+ from pandas._libs.tslibs.dtypes import PeriodDtypeBase
18
+ from pandas._libs.tslibs.nattype import NaTType
19
+ from pandas._libs.tslibs.timedeltas import Timedelta
20
+ from pandas._typing import (
21
+ OffsetCalendar,
22
+ npt,
23
+ )
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 BaseOffset:
33
+ n: int
34
+ normalize: bool
35
+ def __init__(self, n: int = ..., normalize: bool = ...) -> None: ...
36
+ def __eq__(self, other: object, /) -> bool: ...
37
+ def __ne__(self, other: object, /) -> bool: ...
38
+ def __hash__(self) -> int: ...
39
+ @property
40
+ def kwds(self) -> dict: ...
41
+ @property
42
+ def base(self) -> BaseOffset: ...
43
+ @overload
44
+ def __add__(self, other: npt.NDArray[np.object_], /) -> npt.NDArray[np.object_]: ...
45
+ @overload
46
+ def __add__(self, other: BaseOffset, /) -> Self: ...
47
+ @overload
48
+ def __add__(self, other: _DatetimeT, /) -> _DatetimeT: ...
49
+ @overload
50
+ def __add__(self, other: _TimedeltaT, /) -> _TimedeltaT: ...
51
+ @overload
52
+ def __radd__(
53
+ self, other: npt.NDArray[np.object_], /
54
+ ) -> 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__(
66
+ self, other: npt.NDArray[np.object_], /
67
+ ) -> npt.NDArray[np.object_]: ...
68
+ @overload
69
+ def __rsub__(self, other: BaseOffset, /) -> Self: ...
70
+ @overload
71
+ def __rsub__(self, other: _DatetimeT, /) -> _DatetimeT: ...
72
+ @overload
73
+ def __rsub__(self, other: _TimedeltaT, /) -> _TimedeltaT: ...
74
+ @overload
75
+ def __mul__(self, other: np.ndarray, /) -> np.ndarray: ...
76
+ @overload
77
+ def __mul__(self, other: int, /) -> Self: ...
78
+ @overload
79
+ def __rmul__(self, other: np.ndarray, /) -> np.ndarray: ...
80
+ @overload
81
+ def __rmul__(self, other: int, /) -> Self: ...
82
+ def __neg__(self) -> Self: ...
83
+ def copy(self) -> Self: ...
84
+ @property
85
+ def name(self) -> str: ...
86
+ @property
87
+ def rule_code(self) -> str: ...
88
+ @property
89
+ def freqstr(self) -> str: ...
90
+ @property
91
+ def _period_unit(self) -> str: ...
92
+ def _add_datetime(self, other: _DatetimeT) -> _DatetimeT: ...
93
+ def _add_timedelta(self, other: timedelta | np.timedelta64 | BaseOffset) -> Any: ...
94
+ def _add_datetime_ndarray(self, dtarr: np.ndarray) -> np.ndarray: ...
95
+ @property
96
+ def _supports_daily_offset_mask(self) -> bool: ...
97
+ def rollback(self, dt: datetime) -> datetime: ...
98
+ def rollforward(self, dt: datetime) -> datetime: ...
99
+ def is_on_offset(self, dt: datetime) -> bool: ...
100
+ def __setstate__(self, state: dict[str, Any]) -> None: ...
101
+ def __getstate__(self) -> dict[str, Any]: ...
102
+ @property
103
+ def nanos(self) -> int: ...
104
+
105
+ def _get_offset(name: str) -> BaseOffset: ...
106
+
107
+ class SingleConstructorOffset(BaseOffset):
108
+ @classmethod
109
+ def _from_name(cls, suffix: None = ...) -> Self: ...
110
+ def __reduce__(self) -> tuple[type[Self], tuple[Any, ...]]: ...
111
+
112
+ @overload
113
+ def to_offset(freq: None, is_period: bool = ...) -> None: ...
114
+ @overload
115
+ def to_offset(freq: _BaseOffsetT, is_period: bool = ...) -> _BaseOffsetT: ...
116
+ @overload
117
+ def to_offset(
118
+ freq: timedelta | str | PeriodDtypeBase, is_period: bool = ...
119
+ ) -> BaseOffset: ...
120
+
121
+ class Tick(SingleConstructorOffset):
122
+ _creso: int
123
+ _prefix: str
124
+ def __init__(self, n: int = ..., normalize: bool = ...) -> None: ...
125
+ @property
126
+ def nanos(self) -> int: ...
127
+
128
+ def delta_to_tick(delta: timedelta) -> Tick: ...
129
+
130
+ class Day(SingleConstructorOffset): ...
131
+ class Hour(Tick): ...
132
+ class Minute(Tick): ...
133
+ class Second(Tick): ...
134
+ class Milli(Tick): ...
135
+ class Micro(Tick): ...
136
+ class Nano(Tick): ...
137
+
138
+ class RelativeDeltaOffset(BaseOffset):
139
+ _use_relativedelta: bool
140
+ def __init__(self, n: int = ..., normalize: bool = ..., **kwds: Any) -> None: ...
141
+ @property
142
+ def _pd_timedelta(self) -> Timedelta: ...
143
+
144
+ class BusinessMixin(SingleConstructorOffset):
145
+ def __init__(
146
+ self, n: int = ..., normalize: bool = ..., offset: timedelta = ...
147
+ ) -> None: ...
148
+
149
+ class BusinessDay(BusinessMixin): ...
150
+
151
+ class BusinessHour(BusinessMixin):
152
+ def __init__(
153
+ self,
154
+ n: int = ...,
155
+ normalize: bool = ...,
156
+ start: str | time | Collection[str | time] = ...,
157
+ end: str | time | Collection[str | time] = ...,
158
+ offset: timedelta = ...,
159
+ ) -> None: ...
160
+
161
+ class WeekOfMonthMixin(SingleConstructorOffset):
162
+ def __init__(
163
+ self, n: int = ..., normalize: bool = ..., weekday: int = ...
164
+ ) -> None: ...
165
+ @property
166
+ def week(self) -> int: ...
167
+ @property
168
+ def weekday(self) -> int: ...
169
+
170
+ class YearOffset(SingleConstructorOffset):
171
+ def __init__(
172
+ self, n: int = ..., normalize: bool = ..., month: int | None = ...
173
+ ) -> None: ...
174
+ @property
175
+ def month(self) -> int: ...
176
+
177
+ class BYearEnd(YearOffset): ...
178
+ class BYearBegin(YearOffset): ...
179
+
180
+ class YearEnd(YearOffset):
181
+ def __new__(
182
+ cls, n: int = ..., normalize: bool = ..., month: int | None = ...
183
+ ) -> Self: ...
184
+
185
+ class YearBegin(YearOffset): ...
186
+
187
+ class QuarterOffset(SingleConstructorOffset):
188
+ def __init__(
189
+ self, n: int = ..., normalize: bool = ..., startingMonth: int | None = ...
190
+ ) -> None: ...
191
+
192
+ class BQuarterEnd(QuarterOffset): ...
193
+ class BQuarterBegin(QuarterOffset): ...
194
+ class QuarterEnd(QuarterOffset): ...
195
+ class QuarterBegin(QuarterOffset): ...
196
+
197
+ class HalfYearOffset(SingleConstructorOffset):
198
+ def __init__(
199
+ self, n: int = ..., normalize: bool = ..., startingMonth: int | None = ...
200
+ ) -> None: ...
201
+
202
+ class BHalfYearEnd(HalfYearOffset): ...
203
+ class BHalfYearBegin(HalfYearOffset): ...
204
+ class HalfYearEnd(HalfYearOffset): ...
205
+ class HalfYearBegin(HalfYearOffset): ...
206
+ class MonthOffset(SingleConstructorOffset): ...
207
+ class MonthEnd(MonthOffset): ...
208
+ class MonthBegin(MonthOffset): ...
209
+ class BusinessMonthEnd(MonthOffset): ...
210
+ class BusinessMonthBegin(MonthOffset): ...
211
+
212
+ class SemiMonthOffset(SingleConstructorOffset):
213
+ def __init__(
214
+ self, n: int = ..., normalize: bool = ..., day_of_month: int | None = ...
215
+ ) -> None: ...
216
+
217
+ class SemiMonthEnd(SemiMonthOffset): ...
218
+ class SemiMonthBegin(SemiMonthOffset): ...
219
+
220
+ class Week(SingleConstructorOffset):
221
+ def __init__(
222
+ self, n: int = ..., normalize: bool = ..., weekday: int | None = ...
223
+ ) -> None: ...
224
+ @property
225
+ def weekday(self) -> int | None: ...
226
+
227
+ class WeekOfMonth(WeekOfMonthMixin):
228
+ def __init__(
229
+ self, n: int = ..., normalize: bool = ..., week: int = ..., weekday: int = ...
230
+ ) -> None: ...
231
+
232
+ class LastWeekOfMonth(WeekOfMonthMixin):
233
+ def __init__(
234
+ self, n: int = ..., normalize: bool = ..., weekday: int = ...
235
+ ) -> None: ...
236
+
237
+ class FY5253Mixin(SingleConstructorOffset):
238
+ def __init__(
239
+ self,
240
+ n: int = ...,
241
+ normalize: bool = ...,
242
+ weekday: int = ...,
243
+ startingMonth: int = ...,
244
+ variation: Literal["nearest", "last"] = ...,
245
+ ) -> None: ...
246
+
247
+ class FY5253(FY5253Mixin): ...
248
+
249
+ class FY5253Quarter(FY5253Mixin):
250
+ def __init__(
251
+ self,
252
+ n: int = ...,
253
+ normalize: bool = ...,
254
+ weekday: int = ...,
255
+ startingMonth: int = ...,
256
+ qtr_with_extra_week: int = ...,
257
+ variation: Literal["nearest", "last"] = ...,
258
+ ) -> None: ...
259
+
260
+ class Easter(SingleConstructorOffset):
261
+ def __init__(
262
+ self,
263
+ n: int = ...,
264
+ normalize: bool = ...,
265
+ method: int = ...,
266
+ ) -> None: ...
267
+
268
+ class _CustomBusinessMonth(BusinessMixin):
269
+ def __init__(
270
+ self,
271
+ n: int = ...,
272
+ normalize: bool = ...,
273
+ weekmask: str = ...,
274
+ holidays: list | None = ...,
275
+ calendar: OffsetCalendar | None = ...,
276
+ offset: timedelta = ...,
277
+ ) -> None: ...
278
+
279
+ class CustomBusinessDay(BusinessDay):
280
+ def __init__(
281
+ self,
282
+ n: int = ...,
283
+ normalize: bool = ...,
284
+ weekmask: str = ...,
285
+ holidays: list | None = ...,
286
+ calendar: OffsetCalendar | None = ...,
287
+ offset: timedelta = ...,
288
+ ) -> None: ...
289
+
290
+ class CustomBusinessHour(BusinessHour):
291
+ def __init__(
292
+ self,
293
+ n: int = ...,
294
+ normalize: bool = ...,
295
+ weekmask: str = ...,
296
+ holidays: list | None = ...,
297
+ calendar: OffsetCalendar | None = ...,
298
+ start: str | time | Collection[str | time] = ...,
299
+ end: str | time | Collection[str | time] = ...,
300
+ offset: timedelta = ...,
301
+ ) -> None: ...
302
+
303
+ class CustomBusinessMonthEnd(_CustomBusinessMonth):
304
+ def __init__(
305
+ self,
306
+ n: int = ...,
307
+ normalize: bool = ...,
308
+ weekmask: str = ...,
309
+ holidays: list | None = ...,
310
+ calendar: OffsetCalendar | None = ...,
311
+ offset: timedelta = ...,
312
+ ) -> None: ...
313
+
314
+ class CustomBusinessMonthBegin(_CustomBusinessMonth):
315
+ def __init__(
316
+ self,
317
+ n: int = ...,
318
+ normalize: bool = ...,
319
+ weekmask: str = ...,
320
+ holidays: list | None = ...,
321
+ calendar: OffsetCalendar | None = ...,
322
+ offset: timedelta = ...,
323
+ ) -> None: ...
324
+
325
+ class OffsetMeta(type): ...
326
+ class DateOffset(RelativeDeltaOffset, metaclass=OffsetMeta): ...
327
+
328
+ BDay = BusinessDay
329
+ BMonthEnd = BusinessMonthEnd
330
+ BMonthBegin = BusinessMonthBegin
331
+ CBMonthEnd = CustomBusinessMonthEnd
332
+ CBMonthBegin = CustomBusinessMonthBegin
333
+ CDay = CustomBusinessDay
334
+
335
+ def roll_qtrday(
336
+ other: datetime, n: int, month: int, day_opt: str, modby: int
337
+ ) -> int: ...
338
+
339
+ INVALID_FREQ_ERR_MSG: Literal["Invalid frequency: {0}"]
340
+
341
+ def shift_months(
342
+ dtindex: npt.NDArray[np.int64],
343
+ months: int,
344
+ day_opt: str | None = ...,
345
+ reso: int = ...,
346
+ ) -> npt.NDArray[np.int64]: ...
venv/lib/python3.14/site-packages/pandas/_libs/tslibs/parsing.cpython-314-darwin.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:23037a49db8a1bd06342d941a6b76f89f261f5f20910333ad2fbbee80c2b4b3a
3
+ size 285392
venv/lib/python3.14/site-packages/pandas/_libs/tslibs/parsing.pyi ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from collections.abc import Callable
2
+ from datetime import datetime
3
+ from typing import Any
4
+
5
+ import numpy as np
6
+
7
+ from pandas._typing import npt
8
+
9
+ class DateParseError(ValueError): ...
10
+
11
+ def py_parse_datetime_string(
12
+ date_string: str,
13
+ dayfirst: bool = ...,
14
+ yearfirst: bool = ...,
15
+ ) -> datetime: ...
16
+ def parse_datetime_string_with_reso(
17
+ date_string: str,
18
+ freq: str | None = ...,
19
+ dayfirst: bool | None = ...,
20
+ yearfirst: bool | None = ...,
21
+ warn_quarter: bool = ...,
22
+ ) -> tuple[datetime, str]: ...
23
+ def _does_string_look_like_datetime(py_string: str) -> bool: ...
24
+ def quarter_to_myear(year: int, quarter: int, freq: str) -> tuple[int, int]: ...
25
+ def try_parse_dates(
26
+ values: npt.NDArray[np.object_], # object[:]
27
+ parser: Callable[[Any], Any],
28
+ ) -> npt.NDArray[np.object_]: ...
29
+ def guess_datetime_format(
30
+ dt_str: str,
31
+ dayfirst: bool | None = ...,
32
+ ) -> str | None: ...
33
+ def get_rule_month(source: str) -> str: ...
venv/lib/python3.14/site-packages/pandas/_libs/tslibs/period.cpython-314-darwin.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:843c131f8b8e1405714ca7cd338f9c9238baa3f679f51826134f48fe4693df28
3
+ size 424752
venv/lib/python3.14/site-packages/pandas/_libs/tslibs/period.pyi ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Literal
2
+
3
+ import numpy as np
4
+
5
+ from pandas._libs.tslibs.dtypes import PeriodDtypeBase
6
+ from pandas._libs.tslibs.nattype import NaTType
7
+ from pandas._libs.tslibs.offsets import BaseOffset
8
+ from pandas._libs.tslibs.timestamps import Timestamp
9
+ from pandas._typing import (
10
+ Frequency,
11
+ npt,
12
+ )
13
+
14
+ INVALID_FREQ_ERR_MSG: str
15
+ DIFFERENT_FREQ: str
16
+ INT_TO_PERIOD_DEPR_MSG: str
17
+ INT_TO_PERIOD_SCALAR_DEPR_MSG: str
18
+
19
+ class IncompatibleFrequency(TypeError): ...
20
+
21
+ def periodarr_to_dt64arr(
22
+ periodarr: npt.NDArray[np.int64], # const int64_t[:]
23
+ freq: int,
24
+ ) -> npt.NDArray[np.int64]: ...
25
+ def period_asfreq_arr(
26
+ arr: npt.NDArray[np.int64],
27
+ freq1: int,
28
+ freq2: int,
29
+ end: bool,
30
+ ) -> npt.NDArray[np.int64]: ...
31
+ def get_period_field_arr(
32
+ field: str,
33
+ arr: npt.NDArray[np.int64], # const int64_t[:]
34
+ freq: int,
35
+ ) -> npt.NDArray[np.int64]: ...
36
+ def period_ordinals_from_fields(
37
+ years: npt.NDArray[np.int64],
38
+ months: npt.NDArray[np.int64],
39
+ days: npt.NDArray[np.int64],
40
+ hours: npt.NDArray[np.int64],
41
+ minutes: npt.NDArray[np.int64],
42
+ seconds: npt.NDArray[np.int64],
43
+ freq: int,
44
+ ) -> npt.NDArray[np.int64]: ...
45
+ def from_calendar_ordinals(
46
+ values: npt.NDArray[np.int64], # const int64_t[:]
47
+ dtype: PeriodDtypeBase,
48
+ ) -> npt.NDArray[np.int64]: ...
49
+ def extract_ordinals(
50
+ values: npt.NDArray[np.object_],
51
+ dtype: PeriodDtypeBase,
52
+ ) -> npt.NDArray[np.int64]: ...
53
+ def extract_period_unit(
54
+ values: npt.NDArray[np.object_],
55
+ ) -> PeriodDtypeBase: ...
56
+ def period_array_strftime(
57
+ values: npt.NDArray[np.int64],
58
+ dtype_code: int,
59
+ na_rep: str | float,
60
+ date_format: str | None,
61
+ ) -> npt.NDArray[np.object_]: ...
62
+
63
+ # exposed for tests
64
+ def period_asfreq(ordinal: int, freq1: int, freq2: int, end: bool) -> int: ...
65
+ def period_ordinal(
66
+ y: int, m: int, d: int, h: int, min: int, s: int, us: int, ps: int, freq: int
67
+ ) -> int: ...
68
+ def freq_to_dtype_code(freq: BaseOffset) -> int: ...
69
+ def validate_end_alias(how: str) -> Literal["E", "S"]: ...
70
+
71
+ class PeriodMixin:
72
+ @property
73
+ def end_time(self) -> Timestamp: ...
74
+ @property
75
+ def start_time(self) -> Timestamp: ...
76
+ def _require_matching_unit(self, other_unit: str, base: bool = ...) -> None: ...
77
+
78
+ class Period(PeriodMixin):
79
+ ordinal: int # int64_t
80
+ freq: BaseOffset
81
+ _dtype: PeriodDtypeBase
82
+
83
+ # error: "__new__" must return a class instance (got "Union[Period, NaTType]")
84
+ def __new__( # type: ignore[misc]
85
+ cls,
86
+ value: object = ...,
87
+ freq: int | str | BaseOffset | None = ...,
88
+ ordinal: int | None = ...,
89
+ year: int | None = ...,
90
+ month: int | None = ...,
91
+ quarter: int | None = ...,
92
+ day: int | None = ...,
93
+ hour: int | None = ...,
94
+ minute: int | None = ...,
95
+ second: int | None = ...,
96
+ ) -> Period | NaTType: ...
97
+ @classmethod
98
+ def _maybe_convert_freq(cls, freq: object) -> BaseOffset: ...
99
+ @classmethod
100
+ def _from_ordinal(cls, ordinal: int, dtype: PeriodDtypeBase) -> Period: ...
101
+ @classmethod
102
+ def now(cls, freq: Frequency) -> Period: ...
103
+ def __format__(self, fmt: str) -> str: ...
104
+ def strftime(self, fmt: str | None) -> str: ...
105
+ def to_timestamp(
106
+ self,
107
+ freq: str | BaseOffset | None = ...,
108
+ how: str = ...,
109
+ ) -> Timestamp: ...
110
+ def asfreq(self, freq: str | BaseOffset, how: str = ...) -> Period: ...
111
+ @property
112
+ def freqstr(self) -> str: ...
113
+ @property
114
+ def is_leap_year(self) -> bool: ...
115
+ @property
116
+ def daysinmonth(self) -> int: ...
117
+ @property
118
+ def days_in_month(self) -> int: ...
119
+ @property
120
+ def qyear(self) -> int: ...
121
+ @property
122
+ def quarter(self) -> int: ...
123
+ @property
124
+ def day_of_year(self) -> int: ...
125
+ @property
126
+ def weekday(self) -> int: ...
127
+ @property
128
+ def day_of_week(self) -> int: ...
129
+ @property
130
+ def week(self) -> int: ...
131
+ @property
132
+ def weekofyear(self) -> int: ...
133
+ @property
134
+ def second(self) -> int: ...
135
+ @property
136
+ def minute(self) -> int: ...
137
+ @property
138
+ def hour(self) -> int: ...
139
+ @property
140
+ def day(self) -> int: ...
141
+ @property
142
+ def month(self) -> int: ...
143
+ @property
144
+ def year(self) -> int: ...
145
+ def __sub__(self, other: object, /) -> Period | BaseOffset: ...
146
+ def __add__(self, other: object, /) -> Period: ...
venv/lib/python3.14/site-packages/pandas/_libs/tslibs/strptime.cpython-314-darwin.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5bf61ad3b0bd44206b2199a616b2c5fee82cd6009dc8ba20a8a163dbb59a6a30
3
+ size 235984
venv/lib/python3.14/site-packages/pandas/_libs/tslibs/strptime.pyi ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import tzinfo
2
+
3
+ import numpy as np
4
+
5
+ from pandas._typing import npt
6
+
7
+ def format_is_iso(f: str) -> bool: ...
8
+ def array_strptime(
9
+ values: npt.NDArray[np.object_],
10
+ fmt: str | None,
11
+ exact: bool = ...,
12
+ errors: str = ...,
13
+ utc: bool = ...,
14
+ creso: int = ..., # NPY_DATETIMEUNIT
15
+ ) -> tuple[npt.NDArray[np.datetime64], tzinfo | None]: ...
venv/lib/python3.14/site-packages/pandas/_libs/tslibs/timedeltas.cpython-314-darwin.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ff852ab56ca6b2efe6bacf7e8db827aab75abc2da8fc3ecdfcf48985d1baeb79
3
+ size 570544
venv/lib/python3.14/site-packages/pandas/_libs/tslibs/timedeltas.pyi ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import timedelta
2
+ from typing import (
3
+ ClassVar,
4
+ Literal,
5
+ Self,
6
+ TypeAlias,
7
+ overload,
8
+ )
9
+
10
+ import numpy as np
11
+
12
+ from pandas._libs.tslibs import (
13
+ NaTType,
14
+ Tick,
15
+ )
16
+ from pandas._typing import (
17
+ Frequency,
18
+ TimeUnit,
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
+ "s",
43
+ "seconds",
44
+ "sec",
45
+ "second",
46
+ "ms",
47
+ "milliseconds",
48
+ "millisecond",
49
+ "milli",
50
+ "millis",
51
+ "us",
52
+ "microseconds",
53
+ "microsecond",
54
+ "µs",
55
+ "micro",
56
+ "micros",
57
+ "ns",
58
+ "nanoseconds",
59
+ "nano",
60
+ "nanos",
61
+ "nanosecond",
62
+ ]
63
+
64
+ def get_unit_for_round(freq: Frequency | timedelta, creso: int) -> int: ...
65
+ def disallow_ambiguous_unit(unit: str | None) -> None: ...
66
+ def ints_to_pytimedelta(
67
+ m8values: npt.NDArray[np.timedelta64],
68
+ box: bool = ...,
69
+ ) -> npt.NDArray[np.object_]: ...
70
+ def contains_str(values: np.ndarray) -> bool: ...
71
+ def array_to_timedelta64(
72
+ values: npt.NDArray[np.object_],
73
+ unit: str | None = ...,
74
+ errors: str = ...,
75
+ creso: int = ...,
76
+ ) -> np.ndarray: ... # np.ndarray[m8ns]
77
+ def parse_timedelta_unit(unit: str | None) -> UnitChoices: ...
78
+ def parse_timedelta_string_reso(ts: str) -> tuple[Timedelta | NaTType, int]: ...
79
+ def delta_to_nanoseconds(
80
+ delta: np.timedelta64 | timedelta | Tick,
81
+ reso: int = ..., # NPY_DATETIMEUNIT
82
+ round_ok: bool = ...,
83
+ ) -> int: ...
84
+ def floordiv_object_array(
85
+ left: np.ndarray, right: npt.NDArray[np.object_]
86
+ ) -> np.ndarray: ...
87
+ def truediv_object_array(
88
+ left: np.ndarray, right: npt.NDArray[np.object_]
89
+ ) -> np.ndarray: ...
90
+
91
+ class Timedelta(timedelta):
92
+ _creso: int
93
+ min: ClassVar[Timedelta]
94
+ max: ClassVar[Timedelta]
95
+ resolution: ClassVar[Timedelta]
96
+ value: int # np.int64
97
+ _value: int # np.int64
98
+ # error: "__new__" must return a class instance (got "Timedelta | NaTType")
99
+ def __new__( # type: ignore[misc]
100
+ cls: type[Self],
101
+ value: object = ...,
102
+ unit: str | None = ...,
103
+ **kwargs: float | np.integer | np.floating,
104
+ ) -> Self | NaTType: ...
105
+ @classmethod
106
+ def _from_value_and_reso(cls, value: np.int64, reso: int) -> Timedelta: ...
107
+ @property
108
+ def days(self) -> int: ...
109
+ @property
110
+ def seconds(self) -> int: ...
111
+ @property
112
+ def microseconds(self) -> int: ...
113
+ def total_seconds(self) -> float: ...
114
+ def to_pytimedelta(self) -> timedelta: ...
115
+ def to_timedelta64(self) -> np.timedelta64: ...
116
+ @property
117
+ def asm8(self) -> np.timedelta64: ...
118
+ def round(self, freq: Frequency | timedelta) -> Self: ...
119
+ def floor(self, freq: Frequency | timedelta) -> Self: ...
120
+ def ceil(self, freq: Frequency | timedelta) -> Self: ...
121
+ @property
122
+ def resolution_string(self) -> str: ...
123
+ def __add__(self, other: timedelta) -> Timedelta: ...
124
+ def __radd__(self, other: timedelta) -> Timedelta: ...
125
+ def __sub__(self, other: timedelta) -> Timedelta: ...
126
+ def __rsub__(self, other: timedelta) -> Timedelta: ...
127
+ def __neg__(self) -> Timedelta: ...
128
+ def __pos__(self) -> Timedelta: ...
129
+ def __abs__(self) -> Timedelta: ...
130
+ def __mul__(self, other: float) -> Timedelta: ...
131
+ def __rmul__(self, other: float) -> Timedelta: ...
132
+ # error: Signature of "__floordiv__" incompatible with supertype "timedelta"
133
+ @overload # type: ignore[override]
134
+ def __floordiv__(self, other: timedelta) -> int: ...
135
+ @overload
136
+ def __floordiv__(self, other: float) -> Timedelta: ...
137
+ @overload
138
+ def __floordiv__(
139
+ self, other: npt.NDArray[np.timedelta64]
140
+ ) -> npt.NDArray[np.intp]: ...
141
+ @overload
142
+ def __floordiv__(
143
+ self, other: npt.NDArray[np.number]
144
+ ) -> npt.NDArray[np.timedelta64] | Timedelta: ...
145
+ @overload
146
+ def __rfloordiv__(self, other: timedelta | str) -> int: ...
147
+ @overload
148
+ def __rfloordiv__(self, other: NaTType | None) -> NaTType: ...
149
+ @overload
150
+ def __rfloordiv__(self, other: np.ndarray) -> npt.NDArray[np.timedelta64]: ...
151
+ # error: Signature of "__truediv__" incompatible with supertype "datetime.timedelta"
152
+ @overload # type: ignore[override]
153
+ def __truediv__(self, other: Self | timedelta | np.timedelta64, /) -> float: ...
154
+ @overload
155
+ def __truediv__(self, other: float) -> Self: ...
156
+ def __mod__(self, other: timedelta) -> Timedelta: ...
157
+ def __divmod__(self, other: timedelta) -> tuple[int, Timedelta]: ...
158
+ def __le__(self, other: timedelta, /) -> bool: ...
159
+ def __lt__(self, other: timedelta, /) -> bool: ...
160
+ def __ge__(self, other: timedelta, /) -> bool: ...
161
+ def __gt__(self, other: timedelta, /) -> bool: ...
162
+ def __hash__(self) -> int: ...
163
+ def isoformat(self) -> str: ...
164
+ def to_numpy(
165
+ self, dtype: npt.DTypeLike | None = ..., copy: bool = False
166
+ ) -> np.timedelta64: ...
167
+ def view(self, dtype: npt.DTypeLike) -> object: ...
168
+ @property
169
+ def unit(self) -> TimeUnit: ...
170
+ def as_unit(self, unit: TimeUnit, round_ok: bool = ...) -> Timedelta: ...
venv/lib/python3.14/site-packages/pandas/_libs/tslibs/timestamps.cpython-314-darwin.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e38bab2174c2b0650f1eebd3d0d3b98635003055e477112dc9f0f2cfbb5a9786
3
+ size 549168
venv/lib/python3.14/site-packages/pandas/_libs/tslibs/timestamps.pyi ADDED
@@ -0,0 +1,284 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import (
2
+ _IsoCalendarDate,
3
+ date as _date,
4
+ datetime,
5
+ time as _time,
6
+ timedelta,
7
+ tzinfo as _tzinfo,
8
+ )
9
+ from time import struct_time
10
+ from typing import (
11
+ ClassVar,
12
+ Literal,
13
+ Self,
14
+ TypeAlias,
15
+ overload,
16
+ )
17
+
18
+ import numpy as np
19
+
20
+ from pandas._libs.missing import NAType
21
+ from pandas._libs.tslibs import (
22
+ BaseOffset,
23
+ NaTType,
24
+ Period,
25
+ Tick,
26
+ Timedelta,
27
+ )
28
+ from pandas._typing import (
29
+ Frequency,
30
+ TimestampNonexistent,
31
+ TimeUnit,
32
+ )
33
+
34
+ _TimeZones: TypeAlias = str | _tzinfo | int | None
35
+
36
+ def integer_op_not_supported(obj: object) -> TypeError: ...
37
+
38
+ class Timestamp(datetime):
39
+ _creso: int
40
+ min: ClassVar[Timestamp]
41
+ max: ClassVar[Timestamp]
42
+
43
+ resolution: ClassVar[Timedelta]
44
+ _value: int # np.int64
45
+ # error: "__new__" must return a class instance (got "Timestamp | NaTType")
46
+ def __new__( # type: ignore[misc]
47
+ cls: type[Self],
48
+ # null-like input yields NaT; see the Timestamp docstring Notes
49
+ ts_input: (
50
+ np.integer
51
+ | float
52
+ | str
53
+ | _date
54
+ | datetime
55
+ | np.datetime64
56
+ | NaTType
57
+ | NAType
58
+ | None
59
+ ) = ...,
60
+ year: int | None = ...,
61
+ month: int | None = ...,
62
+ day: int | None = ...,
63
+ hour: int | None = ...,
64
+ minute: int | None = ...,
65
+ second: int | None = ...,
66
+ # the 8th positional argument is pydatetime's tzinfo
67
+ microsecond: int | _tzinfo | None = ...,
68
+ tzinfo: _tzinfo | None = ...,
69
+ *,
70
+ nanosecond: int | None = ...,
71
+ tz: _TimeZones = ...,
72
+ unit: str | int | None = ...,
73
+ fold: int | None = ...,
74
+ ) -> Self | NaTType: ...
75
+ @classmethod
76
+ def _from_value_and_reso(
77
+ cls, value: int, reso: int, tz: _TimeZones
78
+ ) -> Timestamp: ...
79
+ @property
80
+ def value(self) -> int: ... # np.int64
81
+ @property
82
+ def year(self) -> int: ...
83
+ @property
84
+ def month(self) -> int: ...
85
+ @property
86
+ def day(self) -> int: ...
87
+ @property
88
+ def hour(self) -> int: ...
89
+ @property
90
+ def minute(self) -> int: ...
91
+ @property
92
+ def second(self) -> int: ...
93
+ @property
94
+ def microsecond(self) -> int: ...
95
+ @property
96
+ def nanosecond(self) -> int: ...
97
+ @property
98
+ def tzinfo(self) -> _tzinfo | None: ...
99
+ @property
100
+ def tz(self) -> _tzinfo | None: ...
101
+ @property
102
+ def fold(self) -> int: ...
103
+ @classmethod
104
+ def fromtimestamp(cls, ts: float, tz: _TimeZones = ...) -> Self: ...
105
+ @classmethod
106
+ def utcfromtimestamp(cls, ts: float) -> Self: ...
107
+ @classmethod
108
+ def today(cls, tz: _TimeZones = ...) -> Self: ...
109
+ @classmethod
110
+ def fromordinal(
111
+ cls,
112
+ ordinal: int,
113
+ tz: _TimeZones = ...,
114
+ ) -> Self: ...
115
+ @classmethod
116
+ def now(cls, tz: _TimeZones = ...) -> Self: ...
117
+ @classmethod
118
+ def utcnow(cls) -> Self: ...
119
+ # error: Signature of "combine" incompatible with supertype "datetime"
120
+ @classmethod
121
+ def combine( # type: ignore[override]
122
+ cls, date: _date, time: _time
123
+ ) -> datetime: ...
124
+ @classmethod
125
+ def fromisoformat(cls, date_string: str) -> Self: ...
126
+ def strftime(self, format: str) -> str: ...
127
+ def __format__(self, fmt: str) -> str: ...
128
+ def toordinal(self) -> int: ...
129
+ def timetuple(self) -> struct_time: ...
130
+ def timestamp(self) -> float: ...
131
+ def utctimetuple(self) -> struct_time: ...
132
+ def date(self) -> _date: ...
133
+ def time(self) -> _time: ...
134
+ def timetz(self) -> _time: ...
135
+ # LSP violation: nanosecond is not present in datetime.datetime.replace
136
+ # and has positional args following it
137
+ def replace( # type: ignore[override]
138
+ self,
139
+ year: int | None = ...,
140
+ month: int | None = ...,
141
+ day: int | None = ...,
142
+ hour: int | None = ...,
143
+ minute: int | None = ...,
144
+ second: int | None = ...,
145
+ microsecond: int | None = ...,
146
+ nanosecond: int | None = ...,
147
+ tzinfo: _tzinfo | type[object] | None = ...,
148
+ fold: int | None = ...,
149
+ ) -> Self: ...
150
+ # LSP violation: datetime.datetime.astimezone has a default value for tz
151
+ def astimezone(self, tz: _TimeZones) -> Self: ... # type: ignore[override]
152
+ def ctime(self) -> str: ...
153
+ def isoformat(self, sep: str = ..., timespec: str = ...) -> str: ...
154
+ @classmethod
155
+ def strptime(
156
+ # Note: strptime is actually disabled and raises NotImplementedError
157
+ cls,
158
+ date_string: str,
159
+ format: str,
160
+ ) -> Self: ...
161
+ def utcoffset(self) -> timedelta | None: ...
162
+ def tzname(self) -> str | None: ...
163
+ def dst(self) -> timedelta | None: ...
164
+ def __le__(self, other: datetime, /) -> bool: ... # type: ignore[override]
165
+ def __lt__(self, other: datetime, /) -> bool: ... # type: ignore[override]
166
+ def __ge__(self, other: datetime, /) -> bool: ... # type: ignore[override]
167
+ def __gt__(self, other: datetime, /) -> bool: ... # type: ignore[override]
168
+ # error: Signature of "__add__" incompatible with supertype "date"/"datetime"
169
+ @overload # type: ignore[override]
170
+ def __add__(self, other: np.ndarray, /) -> np.ndarray: ...
171
+ @overload
172
+ def __add__(self, other: timedelta | np.timedelta64 | Tick, /) -> Self: ...
173
+ def __radd__(self, other: timedelta, /) -> Self: ...
174
+ @overload # type: ignore[override]
175
+ def __sub__(self, other: datetime, /) -> Timedelta: ...
176
+ @overload
177
+ def __sub__(self, other: timedelta | np.timedelta64 | Tick, /) -> Self: ...
178
+ def __hash__(self) -> int: ...
179
+ def weekday(self) -> int: ...
180
+ def isoweekday(self) -> int: ...
181
+ def isocalendar(self) -> _IsoCalendarDate: ...
182
+ @property
183
+ def is_leap_year(self) -> bool: ...
184
+ @property
185
+ def is_month_start(self) -> bool: ...
186
+ @property
187
+ def is_quarter_start(self) -> bool: ...
188
+ @property
189
+ def is_year_start(self) -> bool: ...
190
+ @property
191
+ def is_month_end(self) -> bool: ...
192
+ @property
193
+ def is_quarter_end(self) -> bool: ...
194
+ @property
195
+ def is_year_end(self) -> bool: ...
196
+ def to_pydatetime(self, warn: bool = ...) -> datetime: ...
197
+ def to_datetime64(self) -> np.datetime64: ...
198
+ def to_period(self, freq: BaseOffset | str | None = None) -> Period: ...
199
+ def to_julian_date(self) -> np.float64: ...
200
+ @property
201
+ def asm8(self) -> np.datetime64: ...
202
+ def tz_convert(self, tz: _TimeZones) -> Self: ...
203
+ # TODO: could return NaT?
204
+ def tz_localize(
205
+ self,
206
+ tz: _TimeZones,
207
+ ambiguous: bool | Literal["raise", "NaT"] = ...,
208
+ nonexistent: TimestampNonexistent = ...,
209
+ ) -> Self: ...
210
+ def normalize(self) -> Self: ...
211
+ @overload
212
+ def round(
213
+ self,
214
+ freq: Frequency | timedelta,
215
+ ambiguous: bool | Literal["raise"] = ...,
216
+ nonexistent: (
217
+ Literal["raise", "shift_forward", "shift_backward"] | timedelta
218
+ ) = ...,
219
+ ) -> Self | NaTType: ...
220
+ @overload
221
+ def round(
222
+ self,
223
+ freq: Frequency | timedelta,
224
+ ambiguous: bool | Literal["raise", "NaT"] = ...,
225
+ nonexistent: TimestampNonexistent = ...,
226
+ ) -> Self | NaTType: ...
227
+ @overload
228
+ def floor(
229
+ self,
230
+ freq: Frequency | timedelta,
231
+ ambiguous: bool | Literal["raise"] = ...,
232
+ nonexistent: (
233
+ Literal["raise", "shift_forward", "shift_backward"] | timedelta
234
+ ) = ...,
235
+ ) -> Self | NaTType: ...
236
+ @overload
237
+ def floor(
238
+ self,
239
+ freq: Frequency | timedelta,
240
+ ambiguous: bool | Literal["raise", "NaT"] = ...,
241
+ nonexistent: TimestampNonexistent = ...,
242
+ ) -> Self | NaTType: ...
243
+ @overload
244
+ def ceil(
245
+ self,
246
+ freq: Frequency | timedelta,
247
+ ambiguous: bool | Literal["raise"] = ...,
248
+ nonexistent: (
249
+ Literal["raise", "shift_forward", "shift_backward"] | timedelta
250
+ ) = ...,
251
+ ) -> Self | NaTType: ...
252
+ @overload
253
+ def ceil(
254
+ self,
255
+ freq: Frequency | timedelta,
256
+ ambiguous: bool | Literal["raise", "NaT"] = ...,
257
+ nonexistent: TimestampNonexistent = ...,
258
+ ) -> Self | NaTType: ...
259
+ def day_name(self, locale: str | None = ...) -> str: ...
260
+ def month_name(self, locale: str | None = ...) -> str: ...
261
+ @property
262
+ def day_of_week(self) -> int: ...
263
+ @property
264
+ def dayofweek(self) -> int: ...
265
+ @property
266
+ def day_of_year(self) -> int: ...
267
+ @property
268
+ def dayofyear(self) -> int: ...
269
+ @property
270
+ def quarter(self) -> int: ...
271
+ @property
272
+ def week(self) -> int: ...
273
+ def to_numpy(
274
+ self, dtype: np.dtype | None = ..., copy: bool = ...
275
+ ) -> np.datetime64: ...
276
+ @property
277
+ def _date_repr(self) -> str: ...
278
+ @property
279
+ def days_in_month(self) -> int: ...
280
+ @property
281
+ def daysinmonth(self) -> int: ...
282
+ @property
283
+ def unit(self) -> TimeUnit: ...
284
+ def as_unit(self, unit: TimeUnit, round_ok: bool = ...) -> Timestamp: ...
venv/lib/python3.14/site-packages/pandas/_libs/tslibs/timezones.cpython-314-darwin.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6da7dda16546c16effdf6dcdd6b70d623e0b5aea362ce71842ad4413c8cfc8d9
3
+ size 192688
venv/lib/python3.14/site-packages/pandas/_libs/tslibs/timezones.pyi ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from collections.abc import Callable
2
+ from datetime import (
3
+ datetime,
4
+ tzinfo,
5
+ )
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: ...
venv/lib/python3.14/site-packages/pandas/_libs/tslibs/tzconversion.cpython-314-darwin.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:039bafe57ff119e2839c4908bf4dd52c7c56119ca2bdeb6ce96cde704f2dff4b
3
+ size 194000
venv/lib/python3.14/site-packages/pandas/_libs/tslibs/tzconversion.pyi ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from collections.abc import Iterable
2
+ from datetime import (
3
+ timedelta,
4
+ tzinfo,
5
+ )
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]: ...
venv/lib/python3.14/site-packages/pandas/_libs/tslibs/vectorized.cpython-314-darwin.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8c9490c5ff8804c89319b76a756e607c5d068841f4d8775edb2e8b77c391e5eb
3
+ size 118928
venv/lib/python3.14/site-packages/pandas/_libs/tslibs/vectorized.pyi ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # For cython types that cannot be represented precisely, closest-available
2
+ # python equivalents are used, and the precise types kept as adjacent comments.
3
+ from datetime import tzinfo
4
+
5
+ import numpy as np
6
+
7
+ from pandas._libs.tslibs.dtypes import Resolution
8
+ from pandas._typing import npt
9
+
10
+ def dt64arr_to_periodarr(
11
+ stamps: npt.NDArray[np.int64],
12
+ freq: int,
13
+ tz: tzinfo | None,
14
+ reso: int = ..., # NPY_DATETIMEUNIT
15
+ ) -> npt.NDArray[np.int64]: ...
16
+ def is_date_array_normalized(
17
+ stamps: npt.NDArray[np.int64],
18
+ tz: tzinfo | None,
19
+ reso: int, # NPY_DATETIMEUNIT
20
+ ) -> bool: ...
21
+ def normalize_i8_timestamps(
22
+ stamps: npt.NDArray[np.int64],
23
+ tz: tzinfo | None,
24
+ reso: int, # NPY_DATETIMEUNIT
25
+ ) -> npt.NDArray[np.int64]: ...
26
+ def get_resolution(
27
+ stamps: npt.NDArray[np.int64],
28
+ tz: tzinfo | None = ...,
29
+ reso: int = ..., # NPY_DATETIMEUNIT
30
+ ) -> Resolution: ...
31
+ def ints_to_pydatetime(
32
+ stamps: npt.NDArray[np.int64],
33
+ tz: tzinfo | None = ...,
34
+ box: str = ...,
35
+ reso: int = ..., # NPY_DATETIMEUNIT
36
+ ) -> npt.NDArray[np.object_]: ...
37
+ def tz_convert_from_utc(
38
+ stamps: npt.NDArray[np.int64],
39
+ tz: tzinfo | None,
40
+ reso: int = ..., # NPY_DATETIMEUNIT
41
+ ) -> npt.NDArray[np.int64]: ...
venv/lib/python3.14/site-packages/pandas/_libs/window/__init__.py ADDED
File without changes
venv/lib/python3.14/site-packages/pandas/_libs/window/aggregations.cpython-314-darwin.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:65ea52ab9210b9fc1f5571eae208fb6571dd5536cd824659d71d1d53202498f7
3
+ size 314656
venv/lib/python3.14/site-packages/pandas/_libs/window/aggregations.pyi ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from collections.abc import Callable
2
+ from typing import (
3
+ Any,
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_cov(
46
+ x: np.ndarray, # const float64_t[:]
47
+ y: np.ndarray, # const float64_t[:]
48
+ start: np.ndarray, # np.ndarray[np.int64]
49
+ end: np.ndarray, # np.ndarray[np.int64]
50
+ minp: int, # int64_t
51
+ ddof: int = ...,
52
+ ) -> np.ndarray: ... # np.ndarray[float]
53
+ def roll_corr(
54
+ x: np.ndarray, # const float64_t[:]
55
+ y: np.ndarray, # const float64_t[:]
56
+ start: np.ndarray, # np.ndarray[np.int64]
57
+ end: np.ndarray, # np.ndarray[np.int64]
58
+ minp: int, # int64_t
59
+ ) -> np.ndarray: ... # np.ndarray[float]
60
+ def roll_median_c(
61
+ values: np.ndarray, # np.ndarray[np.float64]
62
+ start: np.ndarray, # np.ndarray[np.int64]
63
+ end: np.ndarray, # np.ndarray[np.int64]
64
+ minp: int, # int64_t
65
+ ) -> np.ndarray: ... # np.ndarray[float]
66
+ def roll_max(
67
+ values: np.ndarray, # np.ndarray[np.float64]
68
+ start: np.ndarray, # np.ndarray[np.int64]
69
+ end: np.ndarray, # np.ndarray[np.int64]
70
+ minp: int, # int64_t
71
+ ) -> np.ndarray: ... # np.ndarray[float]
72
+ def roll_min(
73
+ values: np.ndarray, # np.ndarray[np.float64]
74
+ start: np.ndarray, # np.ndarray[np.int64]
75
+ end: np.ndarray, # np.ndarray[np.int64]
76
+ minp: int, # int64_t
77
+ ) -> np.ndarray: ... # np.ndarray[float]
78
+ def roll_first(
79
+ values: np.ndarray, # np.ndarray[np.float64]
80
+ start: np.ndarray, # np.ndarray[np.int64]
81
+ end: np.ndarray, # np.ndarray[np.int64]
82
+ minp: int, # int64_t
83
+ ) -> np.ndarray: ... # np.ndarray[float]
84
+ def roll_last(
85
+ values: np.ndarray, # np.ndarray[np.float64]
86
+ start: np.ndarray, # np.ndarray[np.int64]
87
+ end: np.ndarray, # np.ndarray[np.int64]
88
+ minp: int, # int64_t
89
+ ) -> np.ndarray: ... # np.ndarray[float]
90
+ def roll_quantile(
91
+ values: np.ndarray, # const float64_t[:]
92
+ start: np.ndarray, # np.ndarray[np.int64]
93
+ end: np.ndarray, # np.ndarray[np.int64]
94
+ minp: int, # int64_t
95
+ quantile: float, # float64_t
96
+ interpolation: Literal["linear", "lower", "higher", "nearest", "midpoint"],
97
+ ) -> np.ndarray: ... # np.ndarray[float]
98
+ def roll_rank(
99
+ values: np.ndarray,
100
+ start: np.ndarray,
101
+ end: np.ndarray,
102
+ minp: int,
103
+ percentile: bool,
104
+ method: WindowingRankType,
105
+ ascending: bool,
106
+ ) -> np.ndarray: ... # np.ndarray[float]
107
+ def roll_nunique(
108
+ values: np.ndarray, # const float64_t[:]
109
+ start: np.ndarray, # np.ndarray[np.int64]
110
+ end: np.ndarray, # np.ndarray[np.int64]
111
+ minp: int, # int64_t
112
+ ) -> np.ndarray: ... # np.ndarray[float]
113
+ def roll_apply(
114
+ obj: object,
115
+ start: np.ndarray, # np.ndarray[np.int64]
116
+ end: np.ndarray, # np.ndarray[np.int64]
117
+ minp: int, # int64_t
118
+ function: Callable[..., Any],
119
+ raw: bool,
120
+ args: tuple[Any, ...],
121
+ kwargs: dict[str, Any],
122
+ ) -> npt.NDArray[np.float64]: ...
123
+ def roll_weighted_sum(
124
+ values: np.ndarray, # const float64_t[:]
125
+ weights: np.ndarray, # const float64_t[:]
126
+ minp: int,
127
+ ) -> np.ndarray: ... # np.ndarray[np.float64]
128
+ def roll_weighted_mean(
129
+ values: np.ndarray, # const float64_t[:]
130
+ weights: np.ndarray, # const float64_t[:]
131
+ minp: int,
132
+ ) -> np.ndarray: ... # np.ndarray[np.float64]
133
+ def roll_weighted_var(
134
+ values: np.ndarray, # const float64_t[:]
135
+ weights: np.ndarray, # const float64_t[:]
136
+ minp: int, # int64_t
137
+ ddof: int, # unsigned int
138
+ ) -> np.ndarray: ... # np.ndarray[np.float64]
139
+ def ewm(
140
+ vals: np.ndarray, # const float64_t[:]
141
+ start: np.ndarray, # const int64_t[:]
142
+ end: np.ndarray, # const int64_t[:]
143
+ minp: int,
144
+ com: float, # float64_t
145
+ adjust: bool,
146
+ ignore_na: bool,
147
+ deltas: np.ndarray | None = None, # const float64_t[:]
148
+ normalize: bool = True,
149
+ ) -> np.ndarray: ... # np.ndarray[np.float64]
150
+ def ewmcov(
151
+ input_x: np.ndarray, # const float64_t[:]
152
+ start: np.ndarray, # const int64_t[:]
153
+ end: np.ndarray, # const int64_t[:]
154
+ minp: int,
155
+ input_y: np.ndarray, # const float64_t[:]
156
+ com: float, # float64_t
157
+ adjust: bool,
158
+ ignore_na: bool,
159
+ bias: bool,
160
+ ) -> np.ndarray: ... # np.ndarray[np.float64]
venv/lib/python3.14/site-packages/pandas/_libs/window/indexers.cpython-314-darwin.so ADDED
Binary file (92.8 kB). View file
 
venv/lib/python3.14/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: int | None, # ignored, exists for compatibility
9
+ center: bool,
10
+ closed: str | None,
11
+ index: np.ndarray, # const int64_t[:]
12
+ ) -> tuple[npt.NDArray[np.int64], npt.NDArray[np.int64]]: ...
venv/lib/python3.14/site-packages/pandas/_libs/writers.cpython-314-darwin.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b00955c29ddade26419bb5ba198dd6892d29290c2a3c1f3ba61530ab5f0aac2e
3
+ size 116384
venv/lib/python3.14/site-packages/pandas/_libs/writers.pyi ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+
3
+ from pandas._typing import ArrayLike
4
+
5
+ def write_csv_rows(
6
+ data: list[ArrayLike],
7
+ data_index: np.ndarray,
8
+ nlevels: int,
9
+ cols: np.ndarray,
10
+ writer: object, # _csv.writer
11
+ ) -> None: ...
12
+ def convert_json_to_lines(arr: str) -> str: ...
13
+ def max_len_string_array(
14
+ arr: np.ndarray, # pandas_string[:]
15
+ ) -> int: ...
16
+ def word_len(val: object) -> int: ...
17
+ def string_array_replace_from_nan_rep(
18
+ arr: np.ndarray, # np.ndarray[object, ndim=1]
19
+ nan_rep: object,
20
+ ) -> None: ...
venv/lib/python3.14/site-packages/pandas/_testing/__init__.py ADDED
@@ -0,0 +1,679 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from concurrent.futures import ThreadPoolExecutor
4
+ from decimal import Decimal
5
+ import operator
6
+ import os
7
+ from sys import byteorder
8
+ import threading
9
+ from typing import (
10
+ TYPE_CHECKING,
11
+ Any,
12
+ )
13
+
14
+ import numpy as np
15
+
16
+ from pandas._config import using_string_dtype
17
+ from pandas._config.localization import (
18
+ can_set_locale,
19
+ get_locales,
20
+ set_locale,
21
+ )
22
+
23
+ from pandas.compat import HAS_PYARROW
24
+
25
+ import pandas as pd
26
+ from pandas import (
27
+ ArrowDtype,
28
+ DataFrame,
29
+ Index,
30
+ MultiIndex,
31
+ RangeIndex,
32
+ Series,
33
+ )
34
+ from pandas._testing._io import (
35
+ round_trip_pathlib,
36
+ round_trip_pickle,
37
+ write_to_compressed,
38
+ )
39
+ from pandas._testing._warnings import (
40
+ assert_produces_warning,
41
+ maybe_produces_warning,
42
+ )
43
+ from pandas._testing.asserters import (
44
+ assert_almost_equal,
45
+ assert_attr_equal,
46
+ assert_categorical_equal,
47
+ assert_class_equal,
48
+ assert_contains_all,
49
+ assert_copy,
50
+ assert_datetime_array_equal,
51
+ assert_dict_equal,
52
+ assert_equal,
53
+ assert_extension_array_equal,
54
+ assert_frame_equal,
55
+ assert_index_equal,
56
+ assert_indexing_slices_equivalent,
57
+ assert_interval_array_equal,
58
+ assert_is_sorted,
59
+ assert_metadata_equivalent,
60
+ assert_numpy_array_equal,
61
+ assert_period_array_equal,
62
+ assert_series_equal,
63
+ assert_sp_array_equal,
64
+ assert_timedelta_array_equal,
65
+ raise_assert_detail,
66
+ )
67
+ from pandas._testing.compat import (
68
+ get_dtype,
69
+ get_obj,
70
+ )
71
+ from pandas._testing.contexts import (
72
+ decompress_file,
73
+ raises_chained_assignment_error,
74
+ set_timezone,
75
+ with_csv_dialect,
76
+ )
77
+ from pandas.core.arrays import (
78
+ ArrowExtensionArray,
79
+ BaseMaskedArray,
80
+ NumpyExtensionArray,
81
+ )
82
+ from pandas.core.arrays._mixins import NDArrayBackedExtensionArray
83
+ from pandas.core.construction import extract_array
84
+
85
+ if TYPE_CHECKING:
86
+ from collections.abc import (
87
+ Callable,
88
+ Iterable,
89
+ )
90
+ from contextlib import AbstractContextManager
91
+
92
+ from pandas._typing import (
93
+ Dtype,
94
+ NpDtype,
95
+ )
96
+
97
+ from pandas.core.arrays import ExtensionArray
98
+
99
+
100
+ UNSIGNED_INT_NUMPY_DTYPES: list[NpDtype] = ["uint8", "uint16", "uint32", "uint64"]
101
+ UNSIGNED_INT_EA_DTYPES: list[Dtype] = ["UInt8", "UInt16", "UInt32", "UInt64"]
102
+ SIGNED_INT_NUMPY_DTYPES: list[NpDtype] = [int, "int8", "int16", "int32", "int64"]
103
+ SIGNED_INT_EA_DTYPES: list[Dtype] = ["Int8", "Int16", "Int32", "Int64"]
104
+ ALL_INT_NUMPY_DTYPES = UNSIGNED_INT_NUMPY_DTYPES + SIGNED_INT_NUMPY_DTYPES
105
+ ALL_INT_EA_DTYPES = UNSIGNED_INT_EA_DTYPES + SIGNED_INT_EA_DTYPES
106
+ ALL_INT_DTYPES: list[Dtype] = [*ALL_INT_NUMPY_DTYPES, *ALL_INT_EA_DTYPES]
107
+
108
+ FLOAT_NUMPY_DTYPES: list[NpDtype] = [float, "float32", "float64"]
109
+ FLOAT_EA_DTYPES: list[Dtype] = ["Float32", "Float64"]
110
+ ALL_FLOAT_DTYPES: list[Dtype] = [*FLOAT_NUMPY_DTYPES, *FLOAT_EA_DTYPES]
111
+
112
+ COMPLEX_DTYPES: list[Dtype] = [complex, "complex64", "complex128"]
113
+ if using_string_dtype():
114
+ STRING_DTYPES: list[Dtype] = ["U"]
115
+ else:
116
+ STRING_DTYPES: list[Dtype] = [str, "str", "U"] # type: ignore[no-redef]
117
+ COMPLEX_FLOAT_DTYPES: list[Dtype] = [*COMPLEX_DTYPES, *FLOAT_NUMPY_DTYPES]
118
+
119
+ DATETIME64_DTYPES: list[Dtype] = ["datetime64[ns]", "M8[ns]"]
120
+ TIMEDELTA64_DTYPES: list[Dtype] = ["timedelta64[ns]", "m8[ns]"]
121
+
122
+ BOOL_DTYPES: list[Dtype] = [bool, "bool"]
123
+ BYTES_DTYPES: list[Dtype] = [bytes, "bytes"]
124
+ OBJECT_DTYPES: list[Dtype] = [object, "object"]
125
+
126
+ ALL_REAL_NUMPY_DTYPES = FLOAT_NUMPY_DTYPES + ALL_INT_NUMPY_DTYPES
127
+ ALL_REAL_EXTENSION_DTYPES = FLOAT_EA_DTYPES + ALL_INT_EA_DTYPES
128
+ ALL_REAL_DTYPES: list[Dtype] = [*ALL_REAL_NUMPY_DTYPES, *ALL_REAL_EXTENSION_DTYPES]
129
+ ALL_NUMERIC_DTYPES: list[Dtype] = [*ALL_REAL_DTYPES, *COMPLEX_DTYPES]
130
+
131
+ ALL_NUMPY_DTYPES = (
132
+ ALL_REAL_NUMPY_DTYPES
133
+ + COMPLEX_DTYPES
134
+ + STRING_DTYPES
135
+ + DATETIME64_DTYPES
136
+ + TIMEDELTA64_DTYPES
137
+ + BOOL_DTYPES
138
+ + OBJECT_DTYPES
139
+ + BYTES_DTYPES
140
+ )
141
+
142
+ NARROW_NP_DTYPES = [
143
+ np.float16,
144
+ np.float32,
145
+ np.int8,
146
+ np.int16,
147
+ np.int32,
148
+ np.uint8,
149
+ np.uint16,
150
+ np.uint32,
151
+ ]
152
+
153
+ PYTHON_DATA_TYPES = [
154
+ str,
155
+ int,
156
+ float,
157
+ complex,
158
+ list,
159
+ tuple,
160
+ range,
161
+ dict,
162
+ set,
163
+ frozenset,
164
+ bool,
165
+ bytes,
166
+ bytearray,
167
+ memoryview,
168
+ ]
169
+
170
+ ENDIAN = {"little": "<", "big": ">"}[byteorder]
171
+
172
+ NULL_OBJECTS = [None, np.nan, pd.NaT, float("nan"), pd.NA, Decimal("NaN")]
173
+ NP_NAT_OBJECTS = [
174
+ cls("NaT", unit)
175
+ for cls in [np.datetime64, np.timedelta64]
176
+ for unit in [
177
+ "Y",
178
+ "M",
179
+ "W",
180
+ "D",
181
+ "h",
182
+ "m",
183
+ "s",
184
+ "ms",
185
+ "us",
186
+ "ns",
187
+ "ps",
188
+ "fs",
189
+ "as",
190
+ ]
191
+ ]
192
+
193
+ if HAS_PYARROW:
194
+ import pyarrow as pa
195
+
196
+ UNSIGNED_INT_PYARROW_DTYPES = [pa.uint8(), pa.uint16(), pa.uint32(), pa.uint64()]
197
+ SIGNED_INT_PYARROW_DTYPES = [pa.int8(), pa.int16(), pa.int32(), pa.int64()]
198
+ ALL_INT_PYARROW_DTYPES = UNSIGNED_INT_PYARROW_DTYPES + SIGNED_INT_PYARROW_DTYPES
199
+ ALL_INT_PYARROW_DTYPES_STR_REPR = [
200
+ str(ArrowDtype(typ)) for typ in ALL_INT_PYARROW_DTYPES
201
+ ]
202
+
203
+ # pa.float16 doesn't seem supported
204
+ # https://github.com/apache/arrow/blob/master/python/pyarrow/src/arrow/python/helpers.cc#L86
205
+ FLOAT_PYARROW_DTYPES = [pa.float32(), pa.float64()]
206
+ FLOAT_PYARROW_DTYPES_STR_REPR = [
207
+ str(ArrowDtype(typ)) for typ in FLOAT_PYARROW_DTYPES
208
+ ]
209
+ DECIMAL_PYARROW_DTYPES = [pa.decimal128(7, 3)]
210
+ STRING_PYARROW_DTYPES = [pa.string()]
211
+ BINARY_PYARROW_DTYPES = [pa.binary()]
212
+
213
+ TIME_PYARROW_DTYPES = [
214
+ pa.time32("s"),
215
+ pa.time32("ms"),
216
+ pa.time64("us"),
217
+ pa.time64("ns"),
218
+ ]
219
+ DATE_PYARROW_DTYPES = [pa.date32(), pa.date64()]
220
+ DATETIME_PYARROW_DTYPES = [
221
+ pa.timestamp(unit=unit, tz=tz)
222
+ for unit in ["s", "ms", "us", "ns"]
223
+ for tz in [None, "UTC", "US/Pacific", "US/Eastern"]
224
+ ]
225
+ TIMEDELTA_PYARROW_DTYPES = [pa.duration(unit) for unit in ["s", "ms", "us", "ns"]]
226
+
227
+ BOOL_PYARROW_DTYPES = [pa.bool_()]
228
+
229
+ # TODO: Add container like pyarrow types:
230
+ # https://arrow.apache.org/docs/python/api/datatypes.html#factory-functions
231
+ ALL_PYARROW_DTYPES = (
232
+ ALL_INT_PYARROW_DTYPES
233
+ + FLOAT_PYARROW_DTYPES
234
+ + DECIMAL_PYARROW_DTYPES
235
+ + STRING_PYARROW_DTYPES
236
+ + BINARY_PYARROW_DTYPES
237
+ + TIME_PYARROW_DTYPES
238
+ + DATE_PYARROW_DTYPES
239
+ + DATETIME_PYARROW_DTYPES
240
+ + TIMEDELTA_PYARROW_DTYPES
241
+ + BOOL_PYARROW_DTYPES
242
+ )
243
+ ALL_REAL_PYARROW_DTYPES_STR_REPR = (
244
+ ALL_INT_PYARROW_DTYPES_STR_REPR + FLOAT_PYARROW_DTYPES_STR_REPR
245
+ )
246
+ else:
247
+ FLOAT_PYARROW_DTYPES_STR_REPR = []
248
+ ALL_INT_PYARROW_DTYPES_STR_REPR = []
249
+ ALL_PYARROW_DTYPES = []
250
+ ALL_REAL_PYARROW_DTYPES_STR_REPR = []
251
+
252
+ ALL_REAL_NULLABLE_DTYPES = (
253
+ FLOAT_NUMPY_DTYPES + ALL_REAL_EXTENSION_DTYPES + ALL_REAL_PYARROW_DTYPES_STR_REPR
254
+ )
255
+
256
+ arithmetic_dunder_methods = [
257
+ "__add__",
258
+ "__radd__",
259
+ "__sub__",
260
+ "__rsub__",
261
+ "__mul__",
262
+ "__rmul__",
263
+ "__floordiv__",
264
+ "__rfloordiv__",
265
+ "__truediv__",
266
+ "__rtruediv__",
267
+ "__pow__",
268
+ "__rpow__",
269
+ "__mod__",
270
+ "__rmod__",
271
+ ]
272
+
273
+ comparison_dunder_methods = ["__eq__", "__ne__", "__le__", "__lt__", "__ge__", "__gt__"]
274
+
275
+ comparison_ops = [
276
+ operator.eq,
277
+ operator.ne,
278
+ operator.gt,
279
+ operator.ge,
280
+ operator.lt,
281
+ operator.le,
282
+ ]
283
+
284
+ numeric_reductions = [
285
+ "count",
286
+ "sum",
287
+ "max",
288
+ "min",
289
+ "mean",
290
+ "prod",
291
+ "std",
292
+ "var",
293
+ "median",
294
+ "kurt",
295
+ "skew",
296
+ "sem",
297
+ ]
298
+
299
+ boolean_reductions = ["all", "any"]
300
+
301
+ all_reductions = numeric_reductions + boolean_reductions
302
+
303
+ numeric_accumulations = ["cumsum", "cumprod", "cummin", "cummax"]
304
+
305
+
306
+ # -----------------------------------------------------------------------------
307
+ # Comparators
308
+
309
+
310
+ def box_expected(expected: Any, box_cls: Any, transpose: bool = True) -> Any:
311
+ """
312
+ Helper function to wrap the expected output of a test in a given box_class.
313
+
314
+ Parameters
315
+ ----------
316
+ expected : np.ndarray, Index, Series
317
+ box_cls : {Index, Series, DataFrame}
318
+
319
+ Returns
320
+ -------
321
+ subclass of box_cls
322
+ """
323
+ if box_cls is pd.array:
324
+ if isinstance(expected, RangeIndex):
325
+ # pd.array would return an IntegerArray
326
+ expected = NumpyExtensionArray(np.asarray(expected._values))
327
+ else:
328
+ expected = pd.array(expected, copy=False)
329
+ elif box_cls is Index:
330
+ expected = Index(expected, copy=False)
331
+ elif box_cls is Series:
332
+ expected = Series(expected)
333
+ elif box_cls is DataFrame:
334
+ expected = Series(expected).to_frame()
335
+ if transpose:
336
+ # for vector operations, we need a DataFrame to be a single-row,
337
+ # not a single-column, in order to operate against non-DataFrame
338
+ # vectors of the same length. But convert to two rows to avoid
339
+ # single-row special cases in datetime arithmetic
340
+ expected = expected.T
341
+ expected = pd.concat([expected] * 2, ignore_index=True)
342
+ elif box_cls is np.ndarray or box_cls is np.array:
343
+ expected = np.array(expected)
344
+ elif box_cls is to_array:
345
+ expected = to_array(expected)
346
+ else:
347
+ raise NotImplementedError(box_cls)
348
+ return expected
349
+
350
+
351
+ def to_array(obj: Any) -> ExtensionArray | np.ndarray:
352
+ """
353
+ Similar to pd.array, but does not cast numpy dtypes to nullable dtypes.
354
+ """
355
+ # temporary implementation until we get pd.array in place
356
+ dtype = getattr(obj, "dtype", None)
357
+
358
+ if dtype is None:
359
+ return np.asarray(obj)
360
+
361
+ return extract_array(obj, extract_numpy=True)
362
+
363
+
364
+ class SubclassedSeries(Series):
365
+ _metadata = ["testattr", "name"]
366
+
367
+ @property
368
+ def _constructor(self) -> Callable: # type: ignore[override]
369
+ # For testing, those properties return a generic callable, and not
370
+ # the actual class. In this case that is equivalent, but it is to
371
+ # ensure we don't rely on the property returning a class
372
+ # See https://github.com/pandas-dev/pandas/pull/46018 and
373
+ # https://github.com/pandas-dev/pandas/issues/32638 and linked issues
374
+ return lambda *args, **kwargs: SubclassedSeries(*args, **kwargs)
375
+
376
+ @property
377
+ def _constructor_expanddim(self) -> Callable:
378
+ return lambda *args, **kwargs: SubclassedDataFrame(*args, **kwargs)
379
+
380
+
381
+ class SubclassedDataFrame(DataFrame):
382
+ _metadata = ["testattr"]
383
+
384
+ @property
385
+ def _constructor(self) -> Callable: # type: ignore[override]
386
+ return lambda *args, **kwargs: SubclassedDataFrame(*args, **kwargs)
387
+
388
+ # error: Cannot override writeable attribute with read-only property
389
+ @property
390
+ def _constructor_sliced(self) -> Callable: # type: ignore[override]
391
+ return lambda *args, **kwargs: SubclassedSeries(*args, **kwargs)
392
+
393
+
394
+ def convert_rows_list_to_csv_str(rows_list: list[str]) -> str:
395
+ """
396
+ Convert list of CSV rows to single CSV-formatted string for current OS.
397
+
398
+ This method is used for creating expected value of to_csv() method.
399
+
400
+ Parameters
401
+ ----------
402
+ rows_list : List[str]
403
+ Each element represents the row of csv.
404
+
405
+ Returns
406
+ -------
407
+ str
408
+ Expected output of to_csv() in current OS.
409
+ """
410
+ sep = os.linesep
411
+ return sep.join(rows_list) + sep
412
+
413
+
414
+ def external_error_raised(
415
+ expected_exception: type[Exception],
416
+ ) -> AbstractContextManager:
417
+ """
418
+ Helper function to mark pytest.raises that have an external error message.
419
+
420
+ Parameters
421
+ ----------
422
+ expected_exception : Exception
423
+ Expected error to raise.
424
+
425
+ Returns
426
+ -------
427
+ Callable
428
+ Regular `pytest.raises` function with `match` equal to `None`.
429
+ """
430
+ import pytest
431
+
432
+ return pytest.raises(expected_exception, match=None)
433
+
434
+
435
+ def get_op_from_name(op_name: str) -> Callable:
436
+ """
437
+ The operator function for a given op name.
438
+
439
+ Parameters
440
+ ----------
441
+ op_name : str
442
+ The op name, in form of "add" or "__add__".
443
+
444
+ Returns
445
+ -------
446
+ function
447
+ A function performing the operation.
448
+ """
449
+ short_opname = op_name.strip("_")
450
+ try:
451
+ op = getattr(operator, short_opname)
452
+ except AttributeError:
453
+ # Assume it is the reverse operator
454
+ rop = getattr(operator, short_opname[1:])
455
+ op = lambda x, y: rop(y, x)
456
+
457
+ return op
458
+
459
+
460
+ # -----------------------------------------------------------------------------
461
+ # Indexing test helpers
462
+
463
+
464
+ def getitem(x: Any) -> Any:
465
+ return x
466
+
467
+
468
+ def setitem(x: Any) -> Any:
469
+ return x
470
+
471
+
472
+ def loc(x: Any) -> Any:
473
+ return x.loc
474
+
475
+
476
+ def iloc(x: Any) -> Any:
477
+ return x.iloc
478
+
479
+
480
+ def at(x: Any) -> Any:
481
+ return x.at
482
+
483
+
484
+ def iat(x: Any) -> Any:
485
+ return x.iat
486
+
487
+
488
+ # -----------------------------------------------------------------------------
489
+
490
+ _UNITS = ["s", "ms", "us", "ns"]
491
+
492
+
493
+ def get_finest_unit(left: str, right: str) -> str:
494
+ """
495
+ Find the higher of two datetime64 units.
496
+ """
497
+ if _UNITS.index(left) >= _UNITS.index(right):
498
+ return left
499
+ return right
500
+
501
+
502
+ def _pa_buffer_addresses(pa_data: pa.ChunkedArray) -> set[int]:
503
+ """
504
+ Addresses of the non-empty buffers backing a pyarrow ChunkedArray.
505
+
506
+ Zero-length buffers are excluded because distinct empty arrays can be
507
+ handed out the same address, which would look like sharing.
508
+ """
509
+ return {
510
+ buf.address
511
+ for chunk in pa_data.iterchunks()
512
+ for buf in chunk.buffers()
513
+ if buf is not None and buf.size > 0
514
+ }
515
+
516
+
517
+ def shares_memory(left: Any, right: Any) -> bool:
518
+ """
519
+ Pandas-compat for np.shares_memory.
520
+ """
521
+ if isinstance(left, np.ndarray) and isinstance(right, np.ndarray):
522
+ return np.shares_memory(left, right)
523
+ elif isinstance(left, np.ndarray):
524
+ # Call with reversed args to get to unpacking logic below.
525
+ return shares_memory(right, left)
526
+
527
+ if isinstance(left, RangeIndex):
528
+ return False
529
+ if isinstance(left, MultiIndex):
530
+ return any(shares_memory(codes, right) for codes in left._codes)
531
+ if isinstance(left, (Index, Series)):
532
+ if isinstance(right, (Index, Series)):
533
+ return shares_memory(left._values, right._values)
534
+ return shares_memory(left._values, right)
535
+
536
+ if isinstance(left, NDArrayBackedExtensionArray):
537
+ return shares_memory(left._ndarray, right)
538
+ if isinstance(left, pd.core.arrays.SparseArray):
539
+ return shares_memory(left.sp_values, right)
540
+ if isinstance(left, pd.core.arrays.IntervalArray):
541
+ return shares_memory(left._left, right) or shares_memory(left._right, right)
542
+
543
+ if isinstance(left, ArrowExtensionArray):
544
+ if isinstance(right, ArrowExtensionArray):
545
+ # https://github.com/pandas-dev/pandas/pull/43930#discussion_r736862669
546
+ left_addrs = _pa_buffer_addresses(left._pa_array)
547
+ right_addrs = _pa_buffer_addresses(right._pa_array)
548
+ return not left_addrs.isdisjoint(right_addrs)
549
+ else:
550
+ # if we have one ArrowExtensionArray and one other array, assume
551
+ # they can only share memory if they share the same numpy buffer
552
+ return np.shares_memory(left, right)
553
+
554
+ if isinstance(left, BaseMaskedArray):
555
+ # By convention, we'll say these share memory if they share *either*
556
+ # the _data or the _mask
557
+ if isinstance(right, BaseMaskedArray):
558
+ return shares_memory(left._data, right._data) or shares_memory(
559
+ left._mask, right._mask
560
+ )
561
+ return shares_memory(left._data, right) or shares_memory(left._mask, right)
562
+
563
+ if isinstance(left, DataFrame) and len(left._mgr.blocks) == 1:
564
+ arr = left._mgr.blocks[0].values
565
+ return shares_memory(arr, right)
566
+
567
+ raise NotImplementedError(type(left), type(right))
568
+
569
+
570
+ def run_multithreaded(
571
+ closure: Callable,
572
+ max_workers: int,
573
+ arguments: Iterable | None = None,
574
+ pass_barrier: bool = False,
575
+ ) -> None:
576
+ with ThreadPoolExecutor(max_workers=max_workers) as tpe:
577
+ if arguments is None:
578
+ arguments = []
579
+ else:
580
+ arguments = list(arguments)
581
+
582
+ if pass_barrier:
583
+ barrier = threading.Barrier(max_workers)
584
+ arguments.append(barrier)
585
+
586
+ try:
587
+ futures = []
588
+ for _ in range(max_workers):
589
+ futures.append(tpe.submit(closure, *arguments)) # noqa: PERF401
590
+ except RuntimeError as e:
591
+ import pytest
592
+
593
+ pytest.skip(
594
+ f"Spawning {max_workers} threads failed with "
595
+ f"error {e!r} (likely due to resource limits on the "
596
+ "system running the tests)"
597
+ )
598
+ finally:
599
+ if len(futures) < max_workers and pass_barrier:
600
+ barrier.abort()
601
+ for f in futures:
602
+ f.result()
603
+
604
+
605
+ __all__ = [
606
+ "ALL_INT_EA_DTYPES",
607
+ "ALL_INT_NUMPY_DTYPES",
608
+ "ALL_NUMPY_DTYPES",
609
+ "ALL_REAL_NUMPY_DTYPES",
610
+ "BOOL_DTYPES",
611
+ "BYTES_DTYPES",
612
+ "COMPLEX_DTYPES",
613
+ "DATETIME64_DTYPES",
614
+ "ENDIAN",
615
+ "FLOAT_EA_DTYPES",
616
+ "FLOAT_NUMPY_DTYPES",
617
+ "NARROW_NP_DTYPES",
618
+ "NP_NAT_OBJECTS",
619
+ "NULL_OBJECTS",
620
+ "OBJECT_DTYPES",
621
+ "SIGNED_INT_EA_DTYPES",
622
+ "SIGNED_INT_NUMPY_DTYPES",
623
+ "STRING_DTYPES",
624
+ "TIMEDELTA64_DTYPES",
625
+ "UNSIGNED_INT_EA_DTYPES",
626
+ "UNSIGNED_INT_NUMPY_DTYPES",
627
+ "SubclassedDataFrame",
628
+ "SubclassedSeries",
629
+ "assert_almost_equal",
630
+ "assert_attr_equal",
631
+ "assert_categorical_equal",
632
+ "assert_class_equal",
633
+ "assert_contains_all",
634
+ "assert_copy",
635
+ "assert_datetime_array_equal",
636
+ "assert_dict_equal",
637
+ "assert_equal",
638
+ "assert_extension_array_equal",
639
+ "assert_frame_equal",
640
+ "assert_index_equal",
641
+ "assert_indexing_slices_equivalent",
642
+ "assert_interval_array_equal",
643
+ "assert_is_sorted",
644
+ "assert_metadata_equivalent",
645
+ "assert_numpy_array_equal",
646
+ "assert_period_array_equal",
647
+ "assert_produces_warning",
648
+ "assert_series_equal",
649
+ "assert_sp_array_equal",
650
+ "assert_timedelta_array_equal",
651
+ "at",
652
+ "box_expected",
653
+ "can_set_locale",
654
+ "convert_rows_list_to_csv_str",
655
+ "decompress_file",
656
+ "external_error_raised",
657
+ "get_dtype",
658
+ "get_finest_unit",
659
+ "get_locales",
660
+ "get_obj",
661
+ "get_op_from_name",
662
+ "getitem",
663
+ "iat",
664
+ "iloc",
665
+ "loc",
666
+ "maybe_produces_warning",
667
+ "raise_assert_detail",
668
+ "raises_chained_assignment_error",
669
+ "round_trip_pathlib",
670
+ "round_trip_pickle",
671
+ "run_multithreaded",
672
+ "set_locale",
673
+ "set_timezone",
674
+ "setitem",
675
+ "shares_memory",
676
+ "to_array",
677
+ "with_csv_dialect",
678
+ "write_to_compressed",
679
+ ]
venv/lib/python3.14/site-packages/pandas/_testing/_io.py ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import gzip
4
+ import io
5
+ import tarfile
6
+ from typing import (
7
+ TYPE_CHECKING,
8
+ Any,
9
+ )
10
+ import zipfile
11
+
12
+ from pandas.compat._optional import import_optional_dependency
13
+
14
+ import pandas as pd
15
+
16
+ if TYPE_CHECKING:
17
+ from collections.abc import Callable
18
+ from pathlib import Path
19
+
20
+ from pandas import (
21
+ DataFrame,
22
+ Series,
23
+ )
24
+
25
+ # ------------------------------------------------------------------
26
+ # File-IO
27
+
28
+
29
+ def round_trip_pickle(obj: Any, tmp_path: Path) -> DataFrame | Series:
30
+ """
31
+ Pickle an object and then read it again.
32
+
33
+ Parameters
34
+ ----------
35
+ obj : any object
36
+ The object to pickle and then re-read.
37
+ tmp_path : Path
38
+ The path where the pickled object is written and then read.
39
+
40
+ Returns
41
+ -------
42
+ pandas object
43
+ The original object that was pickled and then re-read.
44
+ """
45
+ pd.to_pickle(obj, tmp_path)
46
+ return pd.read_pickle(tmp_path)
47
+
48
+
49
+ def round_trip_pathlib(
50
+ writer: Callable[[Path], Any], reader: Callable[[Path], Any], tmp_path: Path
51
+ ) -> DataFrame | Series:
52
+ """
53
+ Write an object to file specified by a pathlib.Path and read it back
54
+
55
+ Parameters
56
+ ----------
57
+ writer : callable bound to pandas object
58
+ IO writing function (e.g. DataFrame.to_csv )
59
+ reader : callable
60
+ IO reading function (e.g. pd.read_csv )
61
+ tmp_path : Path
62
+ The path where the object is written and then read.
63
+
64
+ Returns
65
+ -------
66
+ pandas object
67
+ The original object that was serialized and then re-read.
68
+ """
69
+ writer(tmp_path)
70
+ obj = reader(tmp_path)
71
+ return obj
72
+
73
+
74
+ def write_to_compressed(
75
+ compression: str, path: str, data: bytes, dest: str = "test"
76
+ ) -> None:
77
+ """
78
+ Write data to a compressed file.
79
+
80
+ Parameters
81
+ ----------
82
+ compression : {'gzip', 'bz2', 'zip', 'xz', 'zstd'}
83
+ The compression type to use.
84
+ path : str
85
+ The file path to write the data.
86
+ data : str
87
+ The data to write.
88
+ dest : str, default "test"
89
+ The destination file (for ZIP only)
90
+
91
+ Raises
92
+ ------
93
+ ValueError : An invalid compression value was passed in.
94
+ """
95
+ args: tuple[Any, ...] = (data,)
96
+ mode = "wb"
97
+ method = "write"
98
+ compress_method: Callable[..., Any]
99
+
100
+ if compression == "zip":
101
+ compress_method = zipfile.ZipFile
102
+ mode = "w"
103
+ args = (dest, data)
104
+ method = "writestr"
105
+ elif compression == "tar":
106
+ compress_method = tarfile.TarFile
107
+ mode = "w"
108
+ file = tarfile.TarInfo(name=dest)
109
+ bytes = io.BytesIO(data)
110
+ file.size = len(data)
111
+ args = (file, bytes)
112
+ method = "addfile"
113
+ elif compression == "gzip":
114
+ compress_method = gzip.GzipFile
115
+ elif compression == "bz2":
116
+ import bz2
117
+
118
+ compress_method = bz2.BZ2File
119
+ elif compression == "zstd":
120
+ compress_method = import_optional_dependency("zstandard").open
121
+ elif compression == "xz":
122
+ import lzma
123
+
124
+ compress_method = lzma.LZMAFile
125
+ else:
126
+ raise ValueError(f"Unrecognized compression type: {compression}")
127
+
128
+ # error: No overload variant of "ZipFile" matches argument types "str", "str"
129
+ # error: No overload variant of "BZ2File" matches argument types "str", "str"
130
+ # error: Argument "mode" to "TarFile" has incompatible type "str";
131
+ # expected "Literal['r', 'a', 'w', 'x']
132
+ with compress_method(path, mode=mode) as f: # type: ignore[call-overload, arg-type]
133
+ getattr(f, method)(*args)
venv/lib/python3.14/site-packages/pandas/_testing/_warnings.py ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from contextlib import (
4
+ AbstractContextManager,
5
+ contextmanager,
6
+ nullcontext,
7
+ )
8
+ import inspect
9
+ import re
10
+ import sys
11
+ from typing import (
12
+ TYPE_CHECKING,
13
+ Any,
14
+ Literal,
15
+ cast,
16
+ )
17
+ import warnings
18
+
19
+ from pandas._libs import lib
20
+
21
+ if TYPE_CHECKING:
22
+ from collections.abc import (
23
+ Generator,
24
+ Sequence,
25
+ )
26
+
27
+
28
+ @contextmanager
29
+ def assert_produces_warning(
30
+ expected_warning: type[Warning] | bool | tuple[type[Warning], ...] | None,
31
+ filter_level: Literal[
32
+ "error", "ignore", "always", "default", "module", "once"
33
+ ] = "always",
34
+ check_stacklevel: bool = True,
35
+ raise_on_extra_warnings: bool = True,
36
+ match: str | tuple[str | None, ...] | lib.NoDefault | None = lib.no_default,
37
+ must_find_all_warnings: bool = True,
38
+ ) -> Generator[list[warnings.WarningMessage]]:
39
+ """
40
+ Context manager for running code expected to either raise a specific warning,
41
+ multiple specific warnings, or not raise any warnings. Verifies that the code
42
+ raises the expected warning(s), and that it does not raise any other unexpected
43
+ warnings. It is basically a wrapper around ``warnings.catch_warnings``.
44
+
45
+ Parameters
46
+ ----------
47
+ expected_warning : {Warning, False, tuple[Warning, ...], None}
48
+ The type of Exception raised. ``exception.Warning`` is the base
49
+ class for all warnings. To raise multiple types of exceptions,
50
+ pass them as a tuple. To check that no warning is returned,
51
+ specify ``False`` or ``None``.
52
+ filter_level : str or None, default "always"
53
+ Specifies whether warnings are ignored, displayed, or turned
54
+ into errors.
55
+ Valid values are:
56
+
57
+ * "error" - turns matching warnings into exceptions
58
+ * "ignore" - discard the warning
59
+ * "always" - always emit a warning
60
+ * "default" - print the warning the first time it is generated
61
+ from each location
62
+ * "module" - print the warning the first time it is generated
63
+ from each module
64
+ * "once" - print the warning the first time it is generated
65
+
66
+ check_stacklevel : bool, default True
67
+ If True, displays the line that called the function containing
68
+ the warning to show were the function is called. Otherwise, the
69
+ line that implements the function is displayed.
70
+ raise_on_extra_warnings : bool, default True
71
+ Whether extra warnings not of the type `expected_warning` should
72
+ cause the test to fail.
73
+ match : {str, tuple[str, ...]} or None
74
+ Match warning message. Required whenever a warning is expected; pass
75
+ ``match=None`` to opt out when the message genuinely cannot be
76
+ asserted. If it's a tuple, it has to be the size of
77
+ `expected_warning`. If additionally `must_find_all_warnings` is
78
+ True, each expected warning's message gets matched with a respective
79
+ match. Otherwise, multiple values get treated as an alternative.
80
+ must_find_all_warnings : bool, default True
81
+ If True and `expected_warning` is a tuple, each expected warning
82
+ type must get encountered. Otherwise, even one expected warning
83
+ results in success.
84
+
85
+ Examples
86
+ --------
87
+ >>> import warnings
88
+ >>> with assert_produces_warning(UserWarning, match="hello"):
89
+ ... warnings.warn(UserWarning("hello"))
90
+ >>> with assert_produces_warning(False):
91
+ ... warnings.warn(RuntimeWarning())
92
+ Traceback (most recent call last):
93
+ ...
94
+ AssertionError: Caused unexpected warning(s): ['RuntimeWarning'].
95
+ >>> with assert_produces_warning(UserWarning, match="hello"):
96
+ ... warnings.warn(RuntimeWarning())
97
+ Traceback (most recent call last):
98
+ ...
99
+ AssertionError: Did not see expected warning of class 'UserWarning'.
100
+
101
+ ..warn:: This is *not* thread-safe.
102
+ """
103
+ __tracebackhide__ = True
104
+
105
+ if match is lib.no_default:
106
+ if expected_warning:
107
+ raise TypeError(
108
+ "assert_produces_warning() requires a match argument so the "
109
+ "warning message is checked and not just its class. Pass "
110
+ "match=None if the message genuinely cannot be asserted here."
111
+ )
112
+ match = None
113
+
114
+ with warnings.catch_warnings(record=True) as w:
115
+ warnings.simplefilter(filter_level)
116
+ try:
117
+ yield w
118
+ finally:
119
+ if expected_warning:
120
+ if isinstance(expected_warning, tuple) and must_find_all_warnings:
121
+ match = (
122
+ match
123
+ if isinstance(match, tuple)
124
+ else (match,) * len(expected_warning)
125
+ )
126
+ for warning_type, warning_match in zip(
127
+ expected_warning, match, strict=True
128
+ ):
129
+ _assert_caught_expected_warnings(
130
+ caught_warnings=w,
131
+ expected_warning=warning_type,
132
+ match=warning_match,
133
+ check_stacklevel=check_stacklevel,
134
+ )
135
+ else:
136
+ expected_warning = cast(
137
+ "type[Warning] | tuple[type[Warning], ...]",
138
+ expected_warning,
139
+ )
140
+ match = (
141
+ "|".join(m for m in match if m)
142
+ if isinstance(match, tuple)
143
+ else match
144
+ )
145
+ _assert_caught_expected_warnings(
146
+ caught_warnings=w,
147
+ expected_warning=expected_warning,
148
+ match=match,
149
+ check_stacklevel=check_stacklevel,
150
+ )
151
+ if raise_on_extra_warnings:
152
+ _assert_caught_no_extra_warnings(
153
+ caught_warnings=w,
154
+ expected_warning=expected_warning,
155
+ )
156
+
157
+
158
+ def maybe_produces_warning(
159
+ warning: type[Warning],
160
+ condition: bool,
161
+ *,
162
+ match: str | tuple[str | None, ...] | None,
163
+ **kwargs: Any,
164
+ ) -> AbstractContextManager[list[warnings.WarningMessage] | None]:
165
+ """
166
+ Return a context manager that possibly checks a warning based on the condition
167
+ """
168
+ if condition:
169
+ return assert_produces_warning(warning, match=match, **kwargs)
170
+ else:
171
+ return nullcontext()
172
+
173
+
174
+ def _assert_caught_expected_warnings(
175
+ *,
176
+ caught_warnings: Sequence[warnings.WarningMessage],
177
+ expected_warning: type[Warning] | tuple[type[Warning], ...],
178
+ match: str | None,
179
+ check_stacklevel: bool,
180
+ ) -> None:
181
+ """Assert that there was the expected warning among the caught warnings."""
182
+ saw_warning = False
183
+ matched_message = False
184
+ unmatched_messages = []
185
+ warning_name = (
186
+ tuple(x.__name__ for x in expected_warning)
187
+ if isinstance(expected_warning, tuple)
188
+ else expected_warning.__name__
189
+ )
190
+
191
+ for actual_warning in caught_warnings:
192
+ if issubclass(actual_warning.category, expected_warning):
193
+ saw_warning = True
194
+
195
+ if check_stacklevel:
196
+ _assert_raised_with_correct_stacklevel(actual_warning)
197
+
198
+ if match is not None:
199
+ if re.search(match, str(actual_warning.message)):
200
+ matched_message = True
201
+ else:
202
+ unmatched_messages.append(actual_warning.message)
203
+
204
+ if not saw_warning:
205
+ raise AssertionError(f"Did not see expected warning of class {warning_name!r}")
206
+
207
+ if match and not matched_message:
208
+ raise AssertionError(
209
+ f"Did not see warning {warning_name!r} "
210
+ f"matching '{match}'. The emitted warning messages are "
211
+ f"{unmatched_messages}"
212
+ )
213
+
214
+
215
+ def _assert_caught_no_extra_warnings(
216
+ *,
217
+ caught_warnings: Sequence[warnings.WarningMessage],
218
+ expected_warning: type[Warning] | bool | tuple[type[Warning], ...] | None,
219
+ ) -> None:
220
+ """Assert that no extra warnings apart from the expected ones are caught."""
221
+ extra_warnings = []
222
+
223
+ for actual_warning in caught_warnings:
224
+ if _is_unexpected_warning(actual_warning, expected_warning):
225
+ # GH#38630 pytest.filterwarnings does not suppress these.
226
+ if actual_warning.category == ResourceWarning:
227
+ # GH 44732: Don't make the CI flaky by filtering SSL-related
228
+ # ResourceWarning from dependencies
229
+ if "unclosed <ssl.SSLSocket" in str(actual_warning.message):
230
+ continue
231
+ # GH 44844: Matplotlib leaves font files open during the entire process
232
+ # upon import. Don't make CI flaky if ResourceWarning raised
233
+ # due to these open files.
234
+ if any("matplotlib" in mod for mod in sys.modules):
235
+ continue
236
+ if actual_warning.category == EncodingWarning:
237
+ # EncodingWarnings are checked in the CI
238
+ # pyproject.toml errors on EncodingWarnings in pandas
239
+ # Ignore EncodingWarnings from other libraries
240
+ continue
241
+ extra_warnings.append(
242
+ (
243
+ actual_warning.category.__name__,
244
+ actual_warning.message,
245
+ actual_warning.filename,
246
+ actual_warning.lineno,
247
+ )
248
+ )
249
+
250
+ if extra_warnings:
251
+ raise AssertionError(f"Caused unexpected warning(s): {extra_warnings!r}")
252
+
253
+
254
+ def _is_unexpected_warning(
255
+ actual_warning: warnings.WarningMessage,
256
+ expected_warning: type[Warning] | bool | tuple[type[Warning], ...] | None,
257
+ ) -> bool:
258
+ """Check if the actual warning issued is unexpected."""
259
+ if actual_warning and not expected_warning:
260
+ return True
261
+ expected_warning = cast("type[Warning]", expected_warning)
262
+ return bool(not issubclass(actual_warning.category, expected_warning))
263
+
264
+
265
+ def _assert_raised_with_correct_stacklevel(
266
+ actual_warning: warnings.WarningMessage,
267
+ ) -> None:
268
+ # https://stackoverflow.com/questions/17407119/python-inspect-stack-is-slow
269
+ frame = inspect.currentframe()
270
+ for _ in range(4):
271
+ frame = frame.f_back # type: ignore[union-attr]
272
+ try:
273
+ caller_filename = inspect.getfile(frame) # type: ignore[arg-type]
274
+ finally:
275
+ # See note in
276
+ # https://docs.python.org/3/library/inspect.html#inspect.Traceback
277
+ del frame
278
+ msg = (
279
+ "Warning not set with correct stacklevel. "
280
+ f"File where warning is raised: {actual_warning.filename} != "
281
+ f"{caller_filename}. Warning message: {actual_warning.message}"
282
+ )
283
+ assert actual_warning.filename == caller_filename, msg
venv/lib/python3.14/site-packages/pandas/_testing/asserters.py ADDED
@@ -0,0 +1,1749 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import operator
4
+ from typing import (
5
+ TYPE_CHECKING,
6
+ Any,
7
+ Literal,
8
+ NoReturn,
9
+ cast,
10
+ )
11
+ import warnings
12
+
13
+ import numpy as np
14
+
15
+ from pandas._libs import lib
16
+ from pandas._libs.missing import is_matching_na
17
+ from pandas._libs.sparse import SparseIndex
18
+ import pandas._libs.testing as _testing
19
+ from pandas._libs.tslibs.np_datetime import compare_mismatched_resolutions
20
+ from pandas.errors import Pandas4Warning
21
+ from pandas.util._decorators import (
22
+ deprecate_kwarg,
23
+ set_module,
24
+ )
25
+ from pandas.util._exceptions import find_stack_level
26
+
27
+ from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike
28
+ from pandas.core.dtypes.common import (
29
+ is_bool,
30
+ is_float_dtype,
31
+ is_integer_dtype,
32
+ is_number,
33
+ is_numeric_dtype,
34
+ needs_i8_conversion,
35
+ )
36
+ from pandas.core.dtypes.dtypes import (
37
+ CategoricalDtype,
38
+ DatetimeTZDtype,
39
+ ExtensionDtype,
40
+ NumpyEADtype,
41
+ )
42
+ from pandas.core.dtypes.missing import array_equivalent
43
+
44
+ import pandas as pd
45
+ from pandas import (
46
+ Categorical,
47
+ CategoricalIndex,
48
+ DataFrame,
49
+ DatetimeIndex,
50
+ Index,
51
+ IntervalDtype,
52
+ IntervalIndex,
53
+ MultiIndex,
54
+ PeriodIndex,
55
+ RangeIndex,
56
+ Series,
57
+ TimedeltaIndex,
58
+ )
59
+ from pandas.core.arrays import (
60
+ DatetimeArray,
61
+ ExtensionArray,
62
+ IntervalArray,
63
+ PeriodArray,
64
+ TimedeltaArray,
65
+ )
66
+ from pandas.core.arrays.datetimelike import DatetimeLikeArrayMixin
67
+ from pandas.core.arrays.string_ import StringDtype
68
+ from pandas.core.indexes.api import safe_sort_index
69
+
70
+ from pandas.io.formats.printing import pprint_thing
71
+
72
+ if TYPE_CHECKING:
73
+ from collections.abc import (
74
+ Container,
75
+ Iterable,
76
+ )
77
+
78
+ from pandas._typing import DtypeObj
79
+
80
+
81
+ def assert_almost_equal(
82
+ left: Any,
83
+ right: Any,
84
+ check_dtype: bool | Literal["equiv"] = "equiv",
85
+ rtol: float = 1.0e-5,
86
+ atol: float = 1.0e-8,
87
+ **kwargs: Any,
88
+ ) -> None:
89
+ """
90
+ Check that the left and right objects are approximately equal.
91
+
92
+ By approximately equal, we refer to objects that are numbers or that
93
+ contain numbers which may be equivalent to specific levels of precision.
94
+
95
+ Parameters
96
+ ----------
97
+ left : object
98
+ right : object
99
+ check_dtype : bool or {'equiv'}, default 'equiv'
100
+ Check dtype if both a and b are the same type. If 'equiv' is passed in,
101
+ then `RangeIndex` and `Index` with int64 dtype are also considered
102
+ equivalent when doing type checking.
103
+ rtol : float, default 1e-5
104
+ Relative tolerance. Only applied to numeric dtypes; values of other
105
+ dtypes, such as interval, are always compared exactly.
106
+ atol : float, default 1e-8
107
+ Absolute tolerance. Only applied to numeric dtypes; values of other
108
+ dtypes, such as interval, are always compared exactly.
109
+ """
110
+ if isinstance(left, Index):
111
+ assert_index_equal(
112
+ left,
113
+ right,
114
+ check_exact=False,
115
+ exact=check_dtype,
116
+ rtol=rtol,
117
+ atol=atol,
118
+ **kwargs,
119
+ )
120
+
121
+ elif isinstance(left, Series):
122
+ assert_series_equal(
123
+ left,
124
+ right,
125
+ check_exact=False,
126
+ check_dtype=check_dtype,
127
+ rtol=rtol,
128
+ atol=atol,
129
+ **kwargs,
130
+ )
131
+
132
+ elif isinstance(left, DataFrame):
133
+ assert_frame_equal(
134
+ left,
135
+ right,
136
+ check_exact=False,
137
+ check_dtype=check_dtype,
138
+ rtol=rtol,
139
+ atol=atol,
140
+ **kwargs,
141
+ )
142
+
143
+ else:
144
+ # Other sequences.
145
+ if check_dtype:
146
+ if is_number(left) and is_number(right):
147
+ # Do not compare numeric classes, like np.float64 and float.
148
+ pass
149
+ elif is_bool(left) and is_bool(right):
150
+ # Do not compare bool classes, like np.bool_ and bool.
151
+ pass
152
+ else:
153
+ if isinstance(left, np.ndarray) or isinstance(right, np.ndarray):
154
+ obj = "numpy array"
155
+ else:
156
+ obj = "Input"
157
+ assert_class_equal(left, right, obj=obj)
158
+
159
+ # if we have "equiv", this becomes True
160
+ _testing.assert_almost_equal(
161
+ left, right, check_dtype=bool(check_dtype), rtol=rtol, atol=atol, **kwargs
162
+ )
163
+
164
+
165
+ def _check_isinstance(left: Any, right: Any, cls: type) -> None:
166
+ """
167
+ Helper method for our assert_* methods that ensures that
168
+ the two objects being compared have the right type before
169
+ proceeding with the comparison.
170
+
171
+ Parameters
172
+ ----------
173
+ left : The first object being compared.
174
+ right : The second object being compared.
175
+ cls : The class type to check against.
176
+
177
+ Raises
178
+ ------
179
+ AssertionError : Either `left` or `right` is not an instance of `cls`.
180
+ """
181
+ cls_name = cls.__name__
182
+
183
+ if not isinstance(left, cls):
184
+ raise AssertionError(
185
+ f"{cls_name} Expected type {cls}, found {type(left)} instead"
186
+ )
187
+ if not isinstance(right, cls):
188
+ raise AssertionError(
189
+ f"{cls_name} Expected type {cls}, found {type(right)} instead"
190
+ )
191
+
192
+
193
+ def assert_dict_equal(
194
+ left: dict[Any, Any], right: dict[Any, Any], compare_keys: bool = True
195
+ ) -> None:
196
+ _check_isinstance(left, right, dict)
197
+ _testing.assert_dict_equal(left, right, compare_keys=compare_keys)
198
+
199
+
200
+ def _resolve_check_freq(
201
+ index: Index, check_freq: bool | lib.NoDefault
202
+ ) -> bool | lib.NoDefault:
203
+ """
204
+ Resolve an unspecified check_freq for a Series/DataFrame axis.
205
+
206
+ The hard freq check has long applied only to a flat DatetimeIndex or
207
+ TimedeltaIndex, so preserve that. Freqs nested inside a MultiIndex level or
208
+ inside Categorical categories were not checked before, so those go through
209
+ the deprecation warning in assert_index_equal. GH#51920, GH#66761
210
+ """
211
+ if check_freq is lib.no_default and isinstance(
212
+ index, (DatetimeIndex, TimedeltaIndex)
213
+ ):
214
+ return True
215
+ return check_freq
216
+
217
+
218
+ @set_module("pandas.testing")
219
+ def assert_index_equal(
220
+ left: Index,
221
+ right: Index,
222
+ exact: bool | str | lib.NoDefault = lib.no_default,
223
+ check_names: bool = True,
224
+ check_exact: bool = True,
225
+ check_categorical: bool = True,
226
+ check_order: bool = True,
227
+ rtol: float = 1.0e-5,
228
+ atol: float = 1.0e-8,
229
+ obj: str | None = None,
230
+ *,
231
+ check_freq: bool | lib.NoDefault = lib.no_default,
232
+ ) -> None:
233
+ """
234
+ Check that left and right Index are equal.
235
+
236
+ This function compares two Index objects and raises an ``AssertionError``
237
+ if they are not equal. It provides fine-grained control over which
238
+ attributes to check, including dtype, names, and categorical properties.
239
+
240
+ Parameters
241
+ ----------
242
+ left : Index
243
+ The first index to compare.
244
+ right : Index
245
+ The second index to compare.
246
+ exact : bool or {'equiv'}, default 'equiv'
247
+ Whether to check the Index class, dtype and inferred_type
248
+ are identical. If 'equiv', then RangeIndex can be substituted for
249
+ Index with an int64 dtype as well.
250
+
251
+ .. deprecated:: 3.1.0
252
+ The default value of 'equiv' has been deprecated and will be changed to
253
+ True in the future.
254
+
255
+ check_names : bool, default True
256
+ Whether to check the names attribute.
257
+ check_exact : bool, default True
258
+ Whether to compare number exactly.
259
+ check_categorical : bool, default True
260
+ Whether to compare internal Categorical exactly.
261
+ check_order : bool, default True
262
+ Whether to compare the order of index entries as well as their values.
263
+ If True, both indexes must contain the same elements, in the same order.
264
+ If False, both indexes must contain the same elements, but in any order.
265
+ rtol : float, default 1e-5
266
+ Relative tolerance. Only used when check_exact is False, and only
267
+ applied to numeric dtypes; values of other dtypes, such as interval,
268
+ are always compared exactly.
269
+ atol : float, default 1e-8
270
+ Absolute tolerance. Only used when check_exact is False, and only
271
+ applied to numeric dtypes; values of other dtypes, such as interval,
272
+ are always compared exactly.
273
+ obj : str, default 'Index' or 'MultiIndex'
274
+ Specify object name being compared, internally used to show appropriate
275
+ assertion message.
276
+ check_freq : bool, default True
277
+ Whether to check the ``freq`` attribute on a DatetimeIndex or
278
+ TimedeltaIndex. This check is skipped when ``check_order=False``,
279
+ as sorting does not preserve ``freq``.
280
+
281
+ .. versionadded:: 3.1.0
282
+
283
+ .. deprecated:: 3.1.0
284
+ Currently a ``freq`` mismatch only warns; in a future version
285
+ ``check_freq=True`` will be the default and mismatches will
286
+ raise. Pass ``check_freq`` explicitly to silence the warning.
287
+
288
+ See Also
289
+ --------
290
+ testing.assert_series_equal : Check that two Series are equal.
291
+ testing.assert_frame_equal : Check that two DataFrames are equal.
292
+
293
+ Examples
294
+ --------
295
+ >>> from pandas import testing as tm
296
+ >>> a = pd.Index([1, 2, 3])
297
+ >>> b = pd.Index([1, 2, 3])
298
+ >>> tm.assert_index_equal(a, b)
299
+ """
300
+ __tracebackhide__ = True
301
+
302
+ if obj is None:
303
+ obj = "MultiIndex" if isinstance(left, MultiIndex) else "Index"
304
+
305
+ def _check_rangeindex_index_int(left: Index, right: Index) -> bool:
306
+ return (
307
+ isinstance(left, RangeIndex)
308
+ and isinstance(right, Index)
309
+ and not isinstance(right, RangeIndex)
310
+ and is_integer_dtype(right.dtype)
311
+ ) or (
312
+ isinstance(right, RangeIndex)
313
+ and isinstance(left, Index)
314
+ and not isinstance(left, RangeIndex)
315
+ and is_integer_dtype(left.dtype)
316
+ )
317
+
318
+ if exact is lib.no_default:
319
+ if _check_rangeindex_index_int(left, right):
320
+ warnings.warn(
321
+ "The default value of 'equiv' for the `exact` parameter is deprecated "
322
+ "and will be changed to 'True' in a future version. Please set exact "
323
+ "to the desired value to avoid seeing this warning",
324
+ Pandas4Warning,
325
+ stacklevel=find_stack_level(),
326
+ )
327
+ exact = "equiv"
328
+
329
+ def _check_types(left: Index, right: Index, obj: str = "Index") -> None:
330
+ if not exact:
331
+ return
332
+
333
+ assert_class_equal(left, right, exact=exact, obj=obj)
334
+ assert_attr_equal("inferred_type", left, right, obj=obj)
335
+
336
+ # Skip exact dtype checking when `check_categorical` is False
337
+ if isinstance(left.dtype, CategoricalDtype) and isinstance(
338
+ right.dtype, CategoricalDtype
339
+ ):
340
+ if check_categorical:
341
+ assert_attr_equal("dtype", left, right, obj=obj)
342
+ assert_index_equal(
343
+ cast("CategoricalIndex", left).categories,
344
+ cast("CategoricalIndex", right).categories,
345
+ exact=exact,
346
+ check_freq=check_freq,
347
+ )
348
+ return
349
+
350
+ assert_attr_equal("dtype", left, right, obj=obj)
351
+
352
+ # instance validation
353
+ _check_isinstance(left, right, Index)
354
+
355
+ # class / dtype comparison
356
+ _check_types(left, right, obj=obj)
357
+
358
+ # level comparison
359
+ if left.nlevels != right.nlevels:
360
+ msg1 = f"{obj} levels are different"
361
+ msg2 = f"{left.nlevels}, {left}"
362
+ msg3 = f"{right.nlevels}, {right}"
363
+ raise_assert_detail(obj, msg1, msg2, msg3)
364
+
365
+ # length comparison
366
+ if len(left) != len(right):
367
+ msg1 = f"{obj} length are different"
368
+ msg2 = f"{len(left)}, {left}"
369
+ msg3 = f"{len(right)}, {right}"
370
+ raise_assert_detail(obj, msg1, msg2, msg3)
371
+
372
+ # If order doesn't matter then sort the index entries
373
+ if not check_order:
374
+ left = safe_sort_index(left)
375
+ right = safe_sort_index(right)
376
+
377
+ # MultiIndex special comparison for little-friendly error messages
378
+ if isinstance(left, MultiIndex):
379
+ right = cast("MultiIndex", right)
380
+
381
+ # A freq mismatch in the levels is retried below on get_level_values,
382
+ # which usually drops freq, so the levels comparison must not be what
383
+ # emits the check_freq deprecation warning: it would warn in cases the
384
+ # eventual check_freq=True default accepts. Resolve the sentinel to a
385
+ # hard check here and let the retry decide. GH#66761
386
+ levels_check_freq = True if check_freq is lib.no_default else check_freq
387
+
388
+ for level in range(left.nlevels):
389
+ lobj = f"{obj} level [{level}]"
390
+ try:
391
+ # try comparison on levels/codes to avoid densifying MultiIndex
392
+ assert_index_equal(
393
+ left.levels[level],
394
+ right.levels[level],
395
+ exact=exact,
396
+ check_names=check_names,
397
+ check_exact=check_exact,
398
+ check_categorical=check_categorical,
399
+ check_freq=levels_check_freq,
400
+ rtol=rtol,
401
+ atol=atol,
402
+ obj=lobj,
403
+ )
404
+ assert_numpy_array_equal(left.codes[level], right.codes[level])
405
+ except AssertionError:
406
+ llevel = left.get_level_values(level)
407
+ rlevel = right.get_level_values(level)
408
+
409
+ assert_index_equal(
410
+ llevel,
411
+ rlevel,
412
+ exact=exact,
413
+ check_names=check_names,
414
+ check_exact=check_exact,
415
+ check_categorical=check_categorical,
416
+ check_freq=check_freq,
417
+ rtol=rtol,
418
+ atol=atol,
419
+ obj=lobj,
420
+ )
421
+ # get_level_values may change dtype
422
+ _check_types(left.levels[level], right.levels[level], obj=lobj)
423
+
424
+ # skip exact index checking when `check_categorical` is False
425
+ elif check_exact and check_categorical:
426
+ if not left.equals(right):
427
+ # _values compare can raise TypeError (non-comparable
428
+ # categoricals (GH#61935)
429
+ try:
430
+ mismatch = left._values != right._values
431
+ except TypeError:
432
+ raise_assert_detail(
433
+ obj,
434
+ "types are not comparable (non-matching categorical categories)",
435
+ left,
436
+ right,
437
+ )
438
+
439
+ if not isinstance(mismatch, np.ndarray):
440
+ mismatch = cast("ExtensionArray", mismatch).fillna(True)
441
+
442
+ diff = np.sum(mismatch.astype(int)) * 100.0 / len(left)
443
+ msg = f"{obj} values are different ({np.round(diff, 5)} %)"
444
+ raise_assert_detail(obj, msg, left, right)
445
+ else:
446
+ # if we have "equiv", this becomes True
447
+ exact_bool = bool(exact)
448
+ _testing.assert_almost_equal(
449
+ left._values,
450
+ right._values,
451
+ rtol=rtol,
452
+ atol=atol,
453
+ check_dtype=exact_bool,
454
+ obj=obj,
455
+ lobj=left,
456
+ robj=right,
457
+ )
458
+
459
+ # metadata comparison
460
+ if check_names:
461
+ assert_attr_equal("names", left, right, obj=obj)
462
+ if isinstance(left, PeriodIndex) or isinstance(right, PeriodIndex):
463
+ assert_attr_equal("dtype", left, right, obj=obj)
464
+ if isinstance(left, IntervalIndex) or isinstance(right, IntervalIndex):
465
+ assert_interval_array_equal(
466
+ cast("IntervalArray", left._values),
467
+ cast("IntervalArray", right._values),
468
+ )
469
+
470
+ # freq is not preserved by sorting, so when check_order=False the freqs
471
+ # of the sorted copies are meaningless and the check is skipped
472
+ if (
473
+ check_order
474
+ and isinstance(left, (DatetimeIndex, TimedeltaIndex))
475
+ and isinstance(right, (DatetimeIndex, TimedeltaIndex))
476
+ ):
477
+ if check_freq is lib.no_default:
478
+ if left.freq != right.freq:
479
+ warnings.warn(
480
+ "assert_index_equal will check the 'freq' attribute by "
481
+ f"default in a future version; these freqs {left.freq!r} "
482
+ f"and {right.freq!r} do not match. Pass check_freq=True "
483
+ "or check_freq=False to silence this warning",
484
+ Pandas4Warning,
485
+ stacklevel=find_stack_level(),
486
+ )
487
+ elif check_freq:
488
+ assert_attr_equal("freq", left, right, obj=obj)
489
+
490
+ if check_categorical:
491
+ if isinstance(left.dtype, CategoricalDtype) or isinstance(
492
+ right.dtype, CategoricalDtype
493
+ ):
494
+ assert_categorical_equal(
495
+ cast("Categorical", left._values),
496
+ cast("Categorical", right._values),
497
+ check_freq=check_freq,
498
+ obj=f"{obj} category",
499
+ )
500
+
501
+
502
+ def assert_class_equal(
503
+ left: Any, right: Any, exact: bool | str = True, obj: str = "Input"
504
+ ) -> None:
505
+ """
506
+ Checks classes are equal.
507
+ """
508
+ __tracebackhide__ = True
509
+
510
+ def repr_class(x: Any) -> Any:
511
+ if isinstance(x, Index):
512
+ # return Index as it is to include values in the error message
513
+ return x
514
+
515
+ return type(x).__name__
516
+
517
+ def is_class_equiv(idx: Index) -> bool:
518
+ """Classes that are a RangeIndex (sub-)instance or exactly an `Index` .
519
+
520
+ This only checks class equivalence. There is a separate check that the
521
+ dtype is int64.
522
+ """
523
+ return type(idx) is Index or isinstance(idx, RangeIndex)
524
+
525
+ if type(left) == type(right):
526
+ return
527
+
528
+ if exact == "equiv":
529
+ if is_class_equiv(left) and is_class_equiv(right):
530
+ return
531
+
532
+ msg = f"{obj} classes are different"
533
+ raise_assert_detail(obj, msg, repr_class(left), repr_class(right))
534
+
535
+
536
+ def assert_attr_equal(
537
+ attr: str, left: Any, right: Any, obj: str = "Attributes"
538
+ ) -> None:
539
+ """
540
+ Check attributes are equal. Both objects must have attribute.
541
+
542
+ Parameters
543
+ ----------
544
+ attr : str
545
+ Attribute name being compared.
546
+ left : object
547
+ right : object
548
+ obj : str, default 'Attributes'
549
+ Specify object name being compared, internally used to show appropriate
550
+ assertion message
551
+ """
552
+ __tracebackhide__ = True
553
+
554
+ left_attr = getattr(left, attr)
555
+ right_attr = getattr(right, attr)
556
+
557
+ if left_attr is right_attr or is_matching_na(left_attr, right_attr):
558
+ # e.g. both np.nan, both NaT, both pd.NA, ...
559
+ return None
560
+
561
+ try:
562
+ result = left_attr == right_attr
563
+ except TypeError:
564
+ # datetimetz on rhs may raise TypeError
565
+ result = False
566
+ if (left_attr is pd.NA) ^ (right_attr is pd.NA):
567
+ result = False
568
+ elif not isinstance(result, bool):
569
+ result = result.all()
570
+
571
+ if (
572
+ not result
573
+ and isinstance(left_attr, (tuple, list))
574
+ and type(left_attr) is type(right_attr)
575
+ ):
576
+ # MultiIndex labels (tuples) and Index.names (FrozenList) can contain
577
+ # NA values that == does not treat as equal.
578
+ try:
579
+ result = array_equivalent(
580
+ construct_1d_object_array_from_listlike(left_attr),
581
+ construct_1d_object_array_from_listlike(right_attr),
582
+ strict_nan=True,
583
+ )
584
+ except TypeError:
585
+ result = False
586
+
587
+ if not result:
588
+ msg = f'Attribute "{attr}" are different'
589
+ raise_assert_detail(obj, msg, left_attr, right_attr)
590
+ return None
591
+
592
+
593
+ def assert_is_sorted(seq: Index | Series | np.ndarray | ExtensionArray) -> None:
594
+ """Assert that the sequence is sorted."""
595
+ if isinstance(seq, (Index, Series)):
596
+ seq = seq._values
597
+ # sorting does not change precisions
598
+ if isinstance(seq, np.ndarray):
599
+ assert_numpy_array_equal(seq, np.sort(np.array(seq)))
600
+ else:
601
+ assert_extension_array_equal(seq, seq[seq.argsort()])
602
+
603
+
604
+ def assert_categorical_equal(
605
+ left: Categorical,
606
+ right: Categorical,
607
+ check_dtype: bool = True,
608
+ check_category_order: bool = True,
609
+ obj: str = "Categorical",
610
+ *,
611
+ check_freq: bool | lib.NoDefault = lib.no_default,
612
+ ) -> None:
613
+ """
614
+ Test that Categoricals are equivalent.
615
+
616
+ Parameters
617
+ ----------
618
+ left : Categorical
619
+ right : Categorical
620
+ check_dtype : bool, default True
621
+ Check that integer dtype of the codes are the same.
622
+ check_category_order : bool, default True
623
+ Whether the order of the categories should be compared, which
624
+ implies identical integer codes. If False, only the resulting
625
+ values are compared. The ordered attribute is
626
+ checked regardless.
627
+ obj : str, default 'Categorical'
628
+ Specify object name being compared, internally used to show appropriate
629
+ assertion message.
630
+ check_freq : bool, default True
631
+ Whether to check the ``freq`` attribute of DatetimeIndex or
632
+ TimedeltaIndex categories.
633
+
634
+ .. versionadded:: 3.1.0
635
+
636
+ .. deprecated:: 3.1.0
637
+ Currently a ``freq`` mismatch only warns; in a future version
638
+ ``check_freq=True`` will be the default and mismatches will
639
+ raise. Pass ``check_freq`` explicitly to silence the warning.
640
+ """
641
+ _check_isinstance(left, right, Categorical)
642
+
643
+ exact: bool | str
644
+ if isinstance(left.categories, RangeIndex) or isinstance(
645
+ right.categories, RangeIndex
646
+ ):
647
+ exact = "equiv"
648
+ else:
649
+ # We still want to require exact matches for Index
650
+ exact = True
651
+
652
+ if check_category_order:
653
+ assert_index_equal(
654
+ left.categories,
655
+ right.categories,
656
+ obj=f"{obj}.categories",
657
+ exact=exact,
658
+ check_freq=check_freq,
659
+ )
660
+ assert_numpy_array_equal(
661
+ left.codes, right.codes, check_dtype=check_dtype, obj=f"{obj}.codes"
662
+ )
663
+ else:
664
+ try:
665
+ lc = left.categories.sort_values()
666
+ rc = right.categories.sort_values()
667
+ except TypeError:
668
+ # e.g. '<' not supported between instances of 'int' and 'str'
669
+ lc, rc = left.categories, right.categories
670
+ assert_index_equal(
671
+ lc,
672
+ rc,
673
+ obj=f"{obj}.categories",
674
+ exact=exact,
675
+ check_freq=check_freq,
676
+ )
677
+ # GH#62008 Compare the values as objects. Taking the categories with
678
+ # the raw codes would treat the -1 code used for NA as a positional
679
+ # indexer for the last category, and filling instead would cast
680
+ # integer categories to float64.
681
+ assert_numpy_array_equal(
682
+ left.astype(object),
683
+ right.astype(object),
684
+ obj=f"{obj}.values",
685
+ )
686
+
687
+ assert_attr_equal("ordered", left, right, obj=obj)
688
+
689
+
690
+ def assert_interval_array_equal(
691
+ left: IntervalArray,
692
+ right: IntervalArray,
693
+ obj: str = "IntervalArray",
694
+ ) -> None:
695
+ """
696
+ Test that two IntervalArrays are equivalent.
697
+
698
+ Parameters
699
+ ----------
700
+ left, right : IntervalArray
701
+ The IntervalArrays to compare.
702
+ obj : str, default 'IntervalArray'
703
+ Specify object name being compared, internally used to show appropriate
704
+ assertion message
705
+ """
706
+ _check_isinstance(left, right, IntervalArray)
707
+
708
+ assert_equal(left._left, right._left, obj=f"{obj}.left")
709
+ assert_equal(left._right, right._right, obj=f"{obj}.right")
710
+
711
+ assert_attr_equal("closed", left, right, obj=obj)
712
+
713
+
714
+ def assert_period_array_equal(
715
+ left: PeriodArray, right: PeriodArray, obj: str = "PeriodArray"
716
+ ) -> None:
717
+ _check_isinstance(left, right, PeriodArray)
718
+
719
+ assert_numpy_array_equal(left._ndarray, right._ndarray, obj=f"{obj}._ndarray")
720
+ assert_attr_equal("dtype", left, right, obj=obj)
721
+
722
+
723
+ def assert_datetime_array_equal(
724
+ left: DatetimeArray, right: DatetimeArray, obj: str = "DatetimeArray"
725
+ ) -> None:
726
+ __tracebackhide__ = True
727
+ _check_isinstance(left, right, DatetimeArray)
728
+
729
+ assert_numpy_array_equal(left._ndarray, right._ndarray, obj=f"{obj}._ndarray")
730
+ assert_attr_equal("tz", left, right, obj=obj)
731
+
732
+
733
+ def assert_timedelta_array_equal(
734
+ left: TimedeltaArray, right: TimedeltaArray, obj: str = "TimedeltaArray"
735
+ ) -> None:
736
+ __tracebackhide__ = True
737
+ _check_isinstance(left, right, TimedeltaArray)
738
+ assert_numpy_array_equal(left._ndarray, right._ndarray, obj=f"{obj}._ndarray")
739
+
740
+
741
+ def raise_assert_detail(
742
+ obj: Any,
743
+ message: str,
744
+ left: Any,
745
+ right: Any,
746
+ diff: Any = None,
747
+ first_diff: Any = None,
748
+ index_values: Index | np.ndarray | None = None,
749
+ ) -> NoReturn:
750
+ __tracebackhide__ = True
751
+
752
+ msg = f"""{obj} are different
753
+
754
+ {message}"""
755
+
756
+ if isinstance(index_values, Index):
757
+ index_values = np.asarray(index_values)
758
+
759
+ if isinstance(index_values, np.ndarray):
760
+ msg += f"\n[index]: {pprint_thing(index_values)}"
761
+
762
+ if isinstance(left, np.ndarray):
763
+ left = pprint_thing(left)
764
+ elif isinstance(left, (CategoricalDtype, StringDtype, NumpyEADtype)):
765
+ left = repr(left)
766
+
767
+ if isinstance(right, np.ndarray):
768
+ right = pprint_thing(right)
769
+ elif isinstance(right, (CategoricalDtype, StringDtype, NumpyEADtype)):
770
+ right = repr(right)
771
+
772
+ msg += f"""
773
+ [left]: {left}
774
+ [right]: {right}"""
775
+
776
+ if diff is not None:
777
+ msg += f"\n[diff]: {diff}"
778
+
779
+ if first_diff is not None:
780
+ msg += f"\n{first_diff}"
781
+
782
+ raise AssertionError(msg)
783
+
784
+
785
+ def assert_numpy_array_equal(
786
+ left: Any,
787
+ right: Any,
788
+ strict_nan: bool = False,
789
+ check_dtype: bool | Literal["equiv"] = True,
790
+ err_msg: str | None = None,
791
+ check_same: Literal["copy", "same"] | None = None,
792
+ obj: str = "numpy array",
793
+ index_values: Index | np.ndarray | None = None,
794
+ *,
795
+ class_obj: str | None = None,
796
+ ) -> None:
797
+ """
798
+ Check that 'np.ndarray' is equivalent.
799
+
800
+ Parameters
801
+ ----------
802
+ left, right : numpy.ndarray or iterable
803
+ The two arrays to be compared.
804
+ strict_nan : bool, default False
805
+ If True, consider NaN and None to be different.
806
+ check_dtype : bool, default True
807
+ Check dtype if both a and b are np.ndarray.
808
+ err_msg : str, default None
809
+ If provided, used as assertion message.
810
+ check_same : None|'copy'|'same', default None
811
+ Ensure left and right refer/do not refer to the same memory area.
812
+ obj : str, default 'numpy array'
813
+ Specify object name being compared, internally used to show appropriate
814
+ assertion message.
815
+ index_values : Index | numpy.ndarray, default None
816
+ optional index (shared by both left and right), used in output.
817
+ class_obj : str, default None
818
+ Specify object name for class comparison, internally used to show
819
+ appropriate assertion message.
820
+ """
821
+ __tracebackhide__ = True
822
+
823
+ # instance validation
824
+ # Show a detailed error message when classes are different
825
+ assert_class_equal(left, right, obj=class_obj or obj)
826
+ # both classes must be an np.ndarray
827
+ _check_isinstance(left, right, np.ndarray)
828
+
829
+ def _get_base(obj: np.ndarray) -> Any:
830
+ return obj.base if getattr(obj, "base", None) is not None else obj
831
+
832
+ left_base = _get_base(left)
833
+ right_base = _get_base(right)
834
+
835
+ if check_same == "same":
836
+ if left_base is not right_base:
837
+ raise AssertionError(f"{left_base!r} is not {right_base!r}")
838
+ elif check_same == "copy":
839
+ if left_base is right_base:
840
+ raise AssertionError(f"{left_base!r} is {right_base!r}")
841
+
842
+ def _raise(left: np.ndarray, right: np.ndarray, err_msg: str | None) -> NoReturn:
843
+ if err_msg is None:
844
+ if left.shape != right.shape:
845
+ raise_assert_detail(
846
+ obj, f"{obj} shapes are different", left.shape, right.shape
847
+ )
848
+
849
+ diff = 0.0
850
+ # ravel so the count is over values, matching the `left.size` total
851
+ for left_val, right_val in zip(left.ravel(), right.ravel(), strict=True):
852
+ # count up differences
853
+ if not array_equivalent(left_val, right_val, strict_nan=strict_nan):
854
+ diff += 1
855
+
856
+ diff = diff * 100.0 / left.size
857
+ msg = f"{obj} values are different ({np.round(diff, 5)} %)"
858
+ raise_assert_detail(obj, msg, left, right, index_values=index_values)
859
+
860
+ raise AssertionError(err_msg)
861
+
862
+ # compare shape and values
863
+ if not array_equivalent(left, right, strict_nan=strict_nan):
864
+ _raise(left, right, err_msg)
865
+
866
+ if check_dtype:
867
+ if isinstance(left, np.ndarray) and isinstance(right, np.ndarray):
868
+ assert_attr_equal("dtype", left, right, obj=obj)
869
+
870
+
871
+ @set_module("pandas.testing")
872
+ def assert_extension_array_equal(
873
+ left: ExtensionArray,
874
+ right: ExtensionArray,
875
+ check_dtype: bool | Literal["equiv"] = True,
876
+ index_values: Index | np.ndarray | None = None,
877
+ check_exact: bool | lib.NoDefault = lib.no_default,
878
+ rtol: float | lib.NoDefault = lib.no_default,
879
+ atol: float | lib.NoDefault = lib.no_default,
880
+ obj: str = "ExtensionArray",
881
+ ) -> None:
882
+ """
883
+ Check that left and right ExtensionArrays are equal.
884
+
885
+ This method compares two ``ExtensionArray`` instances for equality,
886
+ including checks for missing values, the dtype of the arrays, and
887
+ the exactness of the comparison (or tolerance when comparing floats).
888
+
889
+ Parameters
890
+ ----------
891
+ left, right : ExtensionArray
892
+ The two arrays to compare.
893
+ check_dtype : bool, default True
894
+ Whether to check if the ExtensionArray dtypes are identical.
895
+ index_values : Index | numpy.ndarray, default None
896
+ Optional index (shared by both left and right), used in output.
897
+ check_exact : bool, default False
898
+ Whether to compare number exactly.
899
+
900
+ .. versionchanged:: 2.2.0
901
+
902
+ Defaults to True for integer dtypes if none of
903
+ ``check_exact``, ``rtol`` and ``atol`` are specified.
904
+ rtol : float, default 1e-5
905
+ Relative tolerance. Only used when check_exact is False, and only
906
+ applied to numeric dtypes; values of other dtypes, such as interval,
907
+ are always compared exactly.
908
+ atol : float, default 1e-8
909
+ Absolute tolerance. Only used when check_exact is False, and only
910
+ applied to numeric dtypes; values of other dtypes, such as interval,
911
+ are always compared exactly.
912
+ obj : str, default 'ExtensionArray'
913
+ Specify object name being compared, internally used to show appropriate
914
+ assertion message.
915
+
916
+ .. versionadded:: 2.0.0
917
+
918
+ See Also
919
+ --------
920
+ testing.assert_series_equal : Check that left and right ``Series`` are equal.
921
+ testing.assert_frame_equal : Check that left and right ``DataFrame`` are equal.
922
+ testing.assert_index_equal : Check that left and right ``Index`` are equal.
923
+
924
+ Notes
925
+ -----
926
+ Missing values are checked separately from valid values.
927
+ A mask of missing values is computed for each and checked to match.
928
+ The remaining all-valid values are cast to object dtype and checked.
929
+
930
+ Examples
931
+ --------
932
+ >>> from pandas import testing as tm
933
+ >>> a = pd.Series([1, 2, 3, 4])
934
+ >>> b, c = a.array, a.array
935
+ >>> tm.assert_extension_array_equal(b, c)
936
+ """
937
+ if (
938
+ check_exact is lib.no_default
939
+ and rtol is lib.no_default
940
+ and atol is lib.no_default
941
+ ):
942
+ check_exact = (
943
+ is_numeric_dtype(left.dtype) and not is_float_dtype(left.dtype)
944
+ ) or (is_numeric_dtype(right.dtype) and not is_float_dtype(right.dtype))
945
+ elif check_exact is lib.no_default:
946
+ check_exact = False
947
+
948
+ rtol = rtol if rtol is not lib.no_default else 1.0e-5
949
+ atol = atol if atol is not lib.no_default else 1.0e-8
950
+
951
+ assert isinstance(left, ExtensionArray), "left is not an ExtensionArray"
952
+ assert isinstance(right, ExtensionArray), "right is not an ExtensionArray"
953
+ if check_dtype:
954
+ assert_attr_equal("dtype", left, right, obj=f"Attributes of {obj}")
955
+
956
+ if (
957
+ isinstance(left, DatetimeLikeArrayMixin)
958
+ and isinstance(right, DatetimeLikeArrayMixin)
959
+ and type(right) == type(left)
960
+ ):
961
+ # GH 52449
962
+ if not check_dtype and left.dtype.kind in "mM":
963
+ if not isinstance(left.dtype, np.dtype):
964
+ l_unit = cast("DatetimeTZDtype", left.dtype).unit
965
+ else:
966
+ l_unit = np.datetime_data(left.dtype)[0]
967
+ if not isinstance(right.dtype, np.dtype):
968
+ r_unit = cast("DatetimeTZDtype", right.dtype).unit
969
+ else:
970
+ r_unit = np.datetime_data(right.dtype)[0]
971
+ if (
972
+ l_unit != r_unit
973
+ and compare_mismatched_resolutions(
974
+ left._ndarray, right._ndarray, operator.eq
975
+ ).all()
976
+ ):
977
+ return
978
+ # Avoid slow object-dtype comparisons
979
+ # np.asarray for case where we have an np.MaskedArray
980
+ assert_numpy_array_equal(
981
+ np.asarray(left.asi8),
982
+ np.asarray(right.asi8),
983
+ index_values=index_values,
984
+ obj=obj,
985
+ )
986
+ return
987
+
988
+ left_na = np.asarray(left.isna())
989
+ right_na = np.asarray(right.isna())
990
+ assert_numpy_array_equal(
991
+ left_na, right_na, obj=f"{obj} NA mask", index_values=index_values
992
+ )
993
+
994
+ # Specifically for StringArrayNumpySemantics, validate here we have a valid array
995
+ if (
996
+ isinstance(left.dtype, StringDtype)
997
+ and left.dtype.storage == "python"
998
+ and left.dtype.na_value is np.nan
999
+ ):
1000
+ assert np.all(
1001
+ [np.isnan(val) for val in left._ndarray[left_na]] # type: ignore[attr-defined]
1002
+ ), "wrong missing value sentinels"
1003
+ if (
1004
+ isinstance(right.dtype, StringDtype)
1005
+ and right.dtype.storage == "python"
1006
+ and right.dtype.na_value is np.nan
1007
+ ):
1008
+ assert np.all(
1009
+ [np.isnan(val) for val in right._ndarray[right_na]] # type: ignore[attr-defined]
1010
+ ), "wrong missing value sentinels"
1011
+
1012
+ left_valid = left[~left_na].to_numpy(dtype=object)
1013
+ right_valid = right[~right_na].to_numpy(dtype=object)
1014
+ if check_exact:
1015
+ assert_numpy_array_equal(
1016
+ left_valid, right_valid, obj=obj, index_values=index_values
1017
+ )
1018
+ else:
1019
+ _testing.assert_almost_equal(
1020
+ left_valid,
1021
+ right_valid,
1022
+ check_dtype=bool(check_dtype),
1023
+ rtol=rtol,
1024
+ atol=atol,
1025
+ obj=obj,
1026
+ index_values=index_values,
1027
+ )
1028
+
1029
+
1030
+ # This could be refactored to use the NDFrame.equals method
1031
+ @set_module("pandas.testing")
1032
+ @deprecate_kwarg(Pandas4Warning, "check_datetimelike_compat", new_arg_name=None)
1033
+ def assert_series_equal(
1034
+ left: Series,
1035
+ right: Series,
1036
+ check_dtype: bool | Literal["equiv"] = True,
1037
+ check_index_type: bool | Literal["equiv"] = "equiv",
1038
+ check_series_type: bool = True,
1039
+ check_names: bool = True,
1040
+ check_exact: bool | lib.NoDefault = lib.no_default,
1041
+ check_datetimelike_compat: bool = False,
1042
+ check_categorical: bool = True,
1043
+ check_category_order: bool = True,
1044
+ check_freq: bool | lib.NoDefault = lib.no_default,
1045
+ check_flags: bool = True,
1046
+ rtol: float | lib.NoDefault = lib.no_default,
1047
+ atol: float | lib.NoDefault = lib.no_default,
1048
+ obj: str = "Series",
1049
+ *,
1050
+ check_index: bool = True,
1051
+ check_like: bool = False,
1052
+ ) -> None:
1053
+ """
1054
+ Check that left and right Series are equal.
1055
+
1056
+ This function compares two Series and raises an ``AssertionError`` if they
1057
+ are not equal. It provides fine-grained control over which attributes to
1058
+ check, including dtype, index, names, and categorical properties.
1059
+
1060
+ Parameters
1061
+ ----------
1062
+ left : Series
1063
+ First Series to compare.
1064
+ right : Series
1065
+ Second Series to compare.
1066
+ check_dtype : bool, default True
1067
+ Whether to check the Series dtype is identical.
1068
+ check_index_type : bool or {'equiv'}, default 'equiv'
1069
+ Whether to check the Index class, dtype and inferred_type
1070
+ are identical.
1071
+ check_series_type : bool, default True
1072
+ Whether to check the Series class is identical.
1073
+ check_names : bool, default True
1074
+ Whether to check the Series and Index names attribute.
1075
+ check_exact : bool, default False
1076
+ Whether to compare number exactly. This also applies when checking
1077
+ Index equivalence.
1078
+
1079
+ .. versionchanged:: 2.2.0
1080
+
1081
+ Defaults to True for integer dtypes if none of
1082
+ ``check_exact``, ``rtol`` and ``atol`` are specified.
1083
+
1084
+ .. versionchanged:: 3.0.0
1085
+
1086
+ check_exact for comparing the Indexes defaults to True by
1087
+ checking if an Index is of integer dtypes.
1088
+
1089
+ When ``check_exact=True``, the comparison of object-dtype values
1090
+ containing nested :class:`numpy.ndarray` objects takes the type of
1091
+ the nested object into account. In particular, a nested
1092
+ ``numpy.ndarray`` is not considered equivalent to a Python
1093
+ ``list``, Python ``tuple``, or a pandas
1094
+ :class:`~pandas.api.extensions.ExtensionArray` merely because the
1095
+ contained values are the same.
1096
+
1097
+ check_datetimelike_compat : bool, default False
1098
+ Compare datetime-like which is comparable ignoring dtype.
1099
+
1100
+ .. deprecated:: 3.0
1101
+
1102
+ check_categorical : bool, default True
1103
+ Whether to compare internal Categorical exactly.
1104
+ check_category_order : bool, default True
1105
+ Whether to compare category order of internal Categoricals.
1106
+ check_freq : bool, default True
1107
+ Whether to check the `freq` attribute on a DatetimeIndex or TimedeltaIndex.
1108
+ The index check is skipped if ``check_index=False`` or ``check_like=True``.
1109
+
1110
+ .. deprecated:: 3.1.0
1111
+ The ``freq`` attribute of a :class:`DatetimeIndex`/
1112
+ :class:`TimedeltaIndex` MultiIndex level or Categorical categories is
1113
+ not yet checked by default; a mismatch currently only warns and will
1114
+ raise in a future version. Pass ``check_freq`` explicitly to silence
1115
+ the warning.
1116
+ check_flags : bool, default True
1117
+ Whether to check the `flags` attribute.
1118
+ rtol : float, default 1e-5
1119
+ Relative tolerance. Only used when check_exact is False, and only
1120
+ applied to numeric dtypes; values of other dtypes, such as interval,
1121
+ are always compared exactly.
1122
+ atol : float, default 1e-8
1123
+ Absolute tolerance. Only used when check_exact is False, and only
1124
+ applied to numeric dtypes; values of other dtypes, such as interval,
1125
+ are always compared exactly.
1126
+ obj : str, default 'Series'
1127
+ Specify object name being compared, internally used to show appropriate
1128
+ assertion message.
1129
+ check_index : bool, default True
1130
+ Whether to check index equivalence. If False, then compare only values.
1131
+ check_like : bool, default False
1132
+ If True, ignore the order of the index. Must be False if check_index is False.
1133
+ Note: same labels must be with the same data.
1134
+
1135
+ See Also
1136
+ --------
1137
+ testing.assert_index_equal : Check that two Indexes are equal.
1138
+ testing.assert_frame_equal : Check that two DataFrames are equal.
1139
+
1140
+ Examples
1141
+ --------
1142
+ >>> from pandas import testing as tm
1143
+ >>> a = pd.Series([1, 2, 3, 4])
1144
+ >>> b = pd.Series([1, 2, 3, 4])
1145
+ >>> tm.assert_series_equal(a, b)
1146
+ """
1147
+ __tracebackhide__ = True
1148
+ if (
1149
+ check_exact is lib.no_default
1150
+ and rtol is lib.no_default
1151
+ and atol is lib.no_default
1152
+ ):
1153
+ check_exact = (
1154
+ is_numeric_dtype(left.dtype) and not is_float_dtype(left.dtype)
1155
+ ) or (is_numeric_dtype(right.dtype) and not is_float_dtype(right.dtype))
1156
+ left_index_dtypes = (
1157
+ [left.index.dtype]
1158
+ if left.index.nlevels == 1
1159
+ else cast("MultiIndex", left.index).dtypes
1160
+ )
1161
+ right_index_dtypes = (
1162
+ [right.index.dtype]
1163
+ if right.index.nlevels == 1
1164
+ else cast("MultiIndex", right.index).dtypes
1165
+ )
1166
+ check_exact_index = all(
1167
+ dtype.kind in "iu" for dtype in left_index_dtypes
1168
+ ) or all(dtype.kind in "iu" for dtype in right_index_dtypes)
1169
+ elif check_exact is lib.no_default:
1170
+ check_exact = False
1171
+ check_exact_index = False
1172
+ else:
1173
+ check_exact_index = check_exact
1174
+
1175
+ rtol = rtol if rtol is not lib.no_default else 1.0e-5
1176
+ atol = atol if atol is not lib.no_default else 1.0e-8
1177
+
1178
+ if not check_index and check_like:
1179
+ raise ValueError("check_like must be False if check_index is False")
1180
+
1181
+ # instance validation
1182
+ _check_isinstance(left, right, Series)
1183
+
1184
+ if check_series_type:
1185
+ assert_class_equal(left, right, obj=obj)
1186
+
1187
+ # length comparison
1188
+ if len(left) != len(right):
1189
+ msg1 = f"{len(left)}, {left.index}"
1190
+ msg2 = f"{len(right)}, {right.index}"
1191
+ raise_assert_detail(obj, "Series length are different", msg1, msg2)
1192
+
1193
+ if check_flags:
1194
+ assert left.flags == right.flags, f"{left.flags!r} != {right.flags!r}"
1195
+
1196
+ if check_index:
1197
+ # GH #38183
1198
+ assert_index_equal(
1199
+ left.index,
1200
+ right.index,
1201
+ exact=check_index_type,
1202
+ check_names=check_names,
1203
+ check_exact=check_exact_index,
1204
+ check_categorical=check_categorical,
1205
+ check_order=not check_like,
1206
+ check_freq=_resolve_check_freq(left.index, check_freq),
1207
+ rtol=rtol,
1208
+ atol=atol,
1209
+ obj=f"{obj}.index",
1210
+ )
1211
+
1212
+ if check_like:
1213
+ left = left.reindex_like(right)
1214
+
1215
+ if check_dtype:
1216
+ # We want to skip exact dtype checking when `check_categorical`
1217
+ # is False. We'll still raise if only one is a `Categorical`,
1218
+ # regardless of `check_categorical`
1219
+ if (
1220
+ isinstance(left.dtype, CategoricalDtype)
1221
+ and isinstance(right.dtype, CategoricalDtype)
1222
+ and not check_categorical
1223
+ ):
1224
+ pass
1225
+ else:
1226
+ assert_attr_equal("dtype", left, right, obj=f"Attributes of {obj}")
1227
+ if check_exact:
1228
+ left_values = left._values
1229
+ right_values = right._values
1230
+ # Only check exact if dtype is numeric
1231
+ if isinstance(left_values, ExtensionArray) and isinstance(
1232
+ right_values, ExtensionArray
1233
+ ):
1234
+ assert_extension_array_equal(
1235
+ left_values,
1236
+ right_values,
1237
+ check_dtype=check_dtype,
1238
+ index_values=left.index,
1239
+ obj=str(obj),
1240
+ )
1241
+ else:
1242
+ # convert both to NumPy if not, check_dtype would raise earlier
1243
+ lv, rv = left_values, right_values
1244
+ if isinstance(left_values, ExtensionArray):
1245
+ lv = left_values.to_numpy()
1246
+ if isinstance(right_values, ExtensionArray):
1247
+ rv = right_values.to_numpy()
1248
+ assert_numpy_array_equal(
1249
+ lv,
1250
+ rv,
1251
+ check_dtype=check_dtype,
1252
+ obj=str(obj),
1253
+ class_obj=f"{obj} values",
1254
+ index_values=left.index,
1255
+ )
1256
+ elif check_datetimelike_compat and (
1257
+ needs_i8_conversion(left.dtype) or needs_i8_conversion(right.dtype)
1258
+ ):
1259
+ # we want to check only if we have compat dtypes
1260
+ # e.g. integer and M|m are NOT compat, but we can simply check
1261
+ # the values in that case
1262
+
1263
+ # datetimelike may have different objects (e.g. datetime.datetime
1264
+ # vs Timestamp) but will compare equal
1265
+ if not Index(left._values).equals(Index(right._values)):
1266
+ msg = (
1267
+ f"[datetimelike_compat=True] {left._values} "
1268
+ f"is not equal to {right._values}."
1269
+ )
1270
+ raise AssertionError(msg)
1271
+ elif isinstance(left.dtype, IntervalDtype) and isinstance(
1272
+ right.dtype, IntervalDtype
1273
+ ):
1274
+ assert_interval_array_equal(
1275
+ cast("IntervalArray", left.array), cast("IntervalArray", right.array)
1276
+ )
1277
+ elif isinstance(left.dtype, CategoricalDtype) or isinstance(
1278
+ right.dtype, CategoricalDtype
1279
+ ):
1280
+ _testing.assert_almost_equal(
1281
+ left._values,
1282
+ right._values,
1283
+ rtol=rtol,
1284
+ atol=atol,
1285
+ check_dtype=bool(check_dtype),
1286
+ obj=str(obj),
1287
+ index_values=left.index,
1288
+ )
1289
+ elif isinstance(left.dtype, ExtensionDtype) and isinstance(
1290
+ right.dtype, ExtensionDtype
1291
+ ):
1292
+ assert_extension_array_equal(
1293
+ left._values,
1294
+ right._values,
1295
+ rtol=rtol,
1296
+ atol=atol,
1297
+ check_dtype=check_dtype,
1298
+ index_values=left.index,
1299
+ obj=str(obj),
1300
+ )
1301
+ elif is_extension_array_dtype_and_needs_i8_conversion(
1302
+ left.dtype, right.dtype
1303
+ ) or is_extension_array_dtype_and_needs_i8_conversion(right.dtype, left.dtype):
1304
+ assert_extension_array_equal(
1305
+ left._values,
1306
+ right._values,
1307
+ check_dtype=check_dtype,
1308
+ index_values=left.index,
1309
+ obj=str(obj),
1310
+ )
1311
+ elif needs_i8_conversion(left.dtype) and needs_i8_conversion(right.dtype):
1312
+ # DatetimeArray or TimedeltaArray
1313
+ assert_extension_array_equal(
1314
+ left._values,
1315
+ right._values,
1316
+ check_dtype=check_dtype,
1317
+ index_values=left.index,
1318
+ obj=str(obj),
1319
+ )
1320
+ else:
1321
+ _testing.assert_almost_equal(
1322
+ left._values,
1323
+ right._values,
1324
+ rtol=rtol,
1325
+ atol=atol,
1326
+ check_dtype=bool(check_dtype),
1327
+ obj=str(obj),
1328
+ index_values=left.index,
1329
+ )
1330
+
1331
+ # metadata comparison
1332
+ if check_names:
1333
+ assert_attr_equal("name", left, right, obj=obj)
1334
+
1335
+ if check_categorical:
1336
+ if isinstance(left.dtype, CategoricalDtype) or isinstance(
1337
+ right.dtype, CategoricalDtype
1338
+ ):
1339
+ assert_categorical_equal(
1340
+ left._values,
1341
+ right._values,
1342
+ obj=f"{obj} category",
1343
+ check_category_order=check_category_order,
1344
+ check_freq=check_freq,
1345
+ )
1346
+
1347
+
1348
+ # This could be refactored to use the NDFrame.equals method
1349
+ @set_module("pandas.testing")
1350
+ @deprecate_kwarg(Pandas4Warning, "check_datetimelike_compat", new_arg_name=None)
1351
+ # stacklevel=3 to account for the extra frame from the stacked decorator above
1352
+ @deprecate_kwarg(Pandas4Warning, "by_blocks", new_arg_name=None, stacklevel=3)
1353
+ def assert_frame_equal(
1354
+ left: DataFrame,
1355
+ right: DataFrame,
1356
+ check_dtype: bool | Literal["equiv"] = True,
1357
+ check_index_type: bool | Literal["equiv"] = "equiv",
1358
+ check_column_type: bool | Literal["equiv"] = "equiv",
1359
+ check_frame_type: bool = True,
1360
+ check_names: bool = True,
1361
+ by_blocks: bool = False,
1362
+ check_exact: bool | lib.NoDefault = lib.no_default,
1363
+ check_datetimelike_compat: bool = False,
1364
+ check_categorical: bool = True,
1365
+ check_like: bool = False,
1366
+ check_freq: bool | lib.NoDefault = lib.no_default,
1367
+ check_flags: bool = True,
1368
+ rtol: float | lib.NoDefault = lib.no_default,
1369
+ atol: float | lib.NoDefault = lib.no_default,
1370
+ obj: str = "DataFrame",
1371
+ ) -> None:
1372
+ """
1373
+ Check that left and right DataFrame are equal.
1374
+
1375
+ This function is intended to compare two DataFrames and output any
1376
+ differences. It is mostly intended for use in unit tests.
1377
+ Additional parameters allow varying the strictness of the
1378
+ equality checks performed.
1379
+
1380
+ Parameters
1381
+ ----------
1382
+ left : DataFrame
1383
+ First DataFrame to compare.
1384
+ right : DataFrame
1385
+ Second DataFrame to compare.
1386
+ check_dtype : bool, default True
1387
+ Whether to check the DataFrame dtype is identical.
1388
+ check_index_type : bool or {'equiv'}, default 'equiv'
1389
+ Whether to check the Index class, dtype and inferred_type
1390
+ are identical.
1391
+ check_column_type : bool or {'equiv'}, default 'equiv'
1392
+ Whether to check the columns class, dtype and inferred_type
1393
+ are identical. Is passed as the ``exact`` argument of
1394
+ :func:`assert_index_equal`.
1395
+ check_frame_type : bool, default True
1396
+ Whether to check the DataFrame class is identical.
1397
+ check_names : bool, default True
1398
+ Whether to check that the `names` attribute for both the `index`
1399
+ and `column` attributes of the DataFrame is identical.
1400
+ by_blocks : bool, default False
1401
+ Specify how to compare internal data. If False, compare by columns.
1402
+ If True, compare by blocks.
1403
+
1404
+ .. deprecated:: 3.1
1405
+ check_exact : bool, default False
1406
+ Whether to compare number exactly. If False, the comparison uses the
1407
+ relative tolerance (``rtol``) and absolute tolerance (``atol``)
1408
+ parameters to determine if two values are considered close,
1409
+ according to the formula: ``|a - b| <= (atol + rtol * |b|)``.
1410
+
1411
+ .. versionchanged:: 2.2.0
1412
+
1413
+ Defaults to True for integer dtypes if none of
1414
+ ``check_exact``, ``rtol`` and ``atol`` are specified.
1415
+
1416
+ .. versionchanged:: 3.0.0
1417
+
1418
+ When ``check_exact=True``, the comparison of object-dtype values
1419
+ containing nested :class:`numpy.ndarray` objects takes the type of
1420
+ the nested object into account. In particular, a nested
1421
+ ``numpy.ndarray`` is not considered equivalent to a Python
1422
+ ``list``, Python ``tuple``, or a pandas
1423
+ :class:`~pandas.api.extensions.ExtensionArray` merely because the
1424
+ contained values are the same.
1425
+
1426
+ check_datetimelike_compat : bool, default False
1427
+ Compare datetime-like which is comparable ignoring dtype.
1428
+
1429
+ .. deprecated:: 3.0
1430
+
1431
+ check_categorical : bool, default True
1432
+ Whether to compare internal Categorical exactly.
1433
+ check_like : bool, default False
1434
+ If True, ignore the order of index & columns.
1435
+ Note: index labels must match their respective rows
1436
+ (same as in columns) - same labels must be with the same data.
1437
+ check_freq : bool, default True
1438
+ Whether to check the `freq` attribute on a DatetimeIndex or TimedeltaIndex
1439
+ index or columns. The index and columns checks are skipped if
1440
+ ``check_like=True``.
1441
+
1442
+ .. deprecated:: 3.1.0
1443
+ The ``freq`` attribute of :class:`DatetimeIndex`/:class:`TimedeltaIndex`
1444
+ columns, MultiIndex levels, and Categorical categories is not yet
1445
+ checked by default; a mismatch currently only warns and will raise in
1446
+ a future version. Pass ``check_freq`` explicitly to silence the
1447
+ warning.
1448
+ check_flags : bool, default True
1449
+ Whether to check the `flags` attribute.
1450
+ rtol : float, default 1e-5
1451
+ Relative tolerance. Only used when check_exact is False, and only
1452
+ applied to numeric dtypes; values of other dtypes, such as interval,
1453
+ are always compared exactly.
1454
+ atol : float, default 1e-8
1455
+ Absolute tolerance. Only used when check_exact is False, and only
1456
+ applied to numeric dtypes; values of other dtypes, such as interval,
1457
+ are always compared exactly.
1458
+ obj : str, default 'DataFrame'
1459
+ Specify object name being compared, internally used to show appropriate
1460
+ assertion message.
1461
+
1462
+ See Also
1463
+ --------
1464
+ assert_series_equal : Equivalent method for asserting Series equality.
1465
+ DataFrame.equals : Check DataFrame equality.
1466
+
1467
+ Examples
1468
+ --------
1469
+ This example shows comparing two DataFrames that are equal
1470
+ but with columns of differing dtypes.
1471
+
1472
+ >>> from pandas.testing import assert_frame_equal
1473
+ >>> df1 = pd.DataFrame({"a": [1, 2], "b": [3, 4]})
1474
+ >>> df2 = pd.DataFrame({"a": [1, 2], "b": [3.0, 4.0]})
1475
+
1476
+ df1 equals itself.
1477
+
1478
+ >>> assert_frame_equal(df1, df1)
1479
+
1480
+ df1 differs from df2 as column 'b' is of a different type.
1481
+
1482
+ >>> assert_frame_equal(df1, df2)
1483
+ Traceback (most recent call last):
1484
+ ...
1485
+ AssertionError: Attributes of DataFrame.iloc[:, 1] (column name="b") are different
1486
+
1487
+ Attribute "dtype" are different
1488
+ [left]: int64
1489
+ [right]: float64
1490
+
1491
+ Ignore differing dtypes in columns with check_dtype.
1492
+
1493
+ >>> assert_frame_equal(df1, df2, check_dtype=False)
1494
+ """
1495
+ __tracebackhide__ = True
1496
+ _rtol = rtol if rtol is not lib.no_default else 1.0e-5
1497
+ _atol = atol if atol is not lib.no_default else 1.0e-8
1498
+ _check_exact = check_exact if check_exact is not lib.no_default else False
1499
+
1500
+ # instance validation
1501
+ _check_isinstance(left, right, DataFrame)
1502
+
1503
+ # The flat-index freq has long been checked by default, so preserve that
1504
+ # hard check; the columns freq check is new and goes through the deprecation
1505
+ # warning in assert_index_equal (passing check_freq unresolved). GH#51920
1506
+ _check_freq = _resolve_check_freq(left.index, check_freq)
1507
+
1508
+ if check_frame_type:
1509
+ assert isinstance(left, type(right))
1510
+ # assert_class_equal(left, right, obj=obj)
1511
+
1512
+ # shape comparison
1513
+ if left.shape != right.shape:
1514
+ raise_assert_detail(
1515
+ obj, f"{obj} shape mismatch", f"{left.shape!r}", f"{right.shape!r}"
1516
+ )
1517
+
1518
+ if check_flags:
1519
+ assert left.flags == right.flags, f"{left.flags!r} != {right.flags!r}"
1520
+
1521
+ # index comparison
1522
+ assert_index_equal(
1523
+ left.index,
1524
+ right.index,
1525
+ exact=check_index_type,
1526
+ check_names=check_names,
1527
+ check_exact=_check_exact,
1528
+ check_categorical=check_categorical,
1529
+ check_order=not check_like,
1530
+ check_freq=_check_freq,
1531
+ rtol=_rtol,
1532
+ atol=_atol,
1533
+ obj=f"{obj}.index",
1534
+ )
1535
+
1536
+ # column comparison
1537
+ assert_index_equal(
1538
+ left.columns,
1539
+ right.columns,
1540
+ exact=check_column_type,
1541
+ check_names=check_names,
1542
+ check_exact=_check_exact,
1543
+ check_categorical=check_categorical,
1544
+ check_order=not check_like,
1545
+ check_freq=check_freq,
1546
+ rtol=_rtol,
1547
+ atol=_atol,
1548
+ obj=f"{obj}.columns",
1549
+ )
1550
+
1551
+ if check_like:
1552
+ left = left.reindex_like(right)
1553
+
1554
+ # compare by blocks
1555
+ if by_blocks:
1556
+ rblocks = right._to_dict_of_blocks()
1557
+ lblocks = left._to_dict_of_blocks()
1558
+ for dtype in list(set(list(lblocks.keys()) + list(rblocks.keys()))):
1559
+ assert dtype in lblocks
1560
+ assert dtype in rblocks
1561
+ assert_frame_equal(
1562
+ lblocks[dtype],
1563
+ rblocks[dtype],
1564
+ check_dtype=check_dtype,
1565
+ check_freq=check_freq,
1566
+ obj=obj,
1567
+ )
1568
+
1569
+ # compare by columns
1570
+ else:
1571
+ for i, col in enumerate(left.columns):
1572
+ # We have already checked that columns match, so we can do
1573
+ # fast location-based lookups
1574
+ lcol = left._ixs(i, axis=1)
1575
+ rcol = right._ixs(i, axis=1)
1576
+
1577
+ # GH #38183
1578
+ # use check_index=False, because we do not want to run
1579
+ # assert_index_equal for each column,
1580
+ # as we already checked it for the whole dataframe before.
1581
+ with warnings.catch_warnings():
1582
+ warnings.filterwarnings(
1583
+ "ignore",
1584
+ message="the 'check_datetimelike_compat' keyword",
1585
+ category=Pandas4Warning,
1586
+ )
1587
+ assert_series_equal(
1588
+ lcol,
1589
+ rcol,
1590
+ check_dtype=check_dtype,
1591
+ check_index_type=check_index_type,
1592
+ check_exact=check_exact,
1593
+ check_names=check_names,
1594
+ check_datetimelike_compat=check_datetimelike_compat,
1595
+ check_categorical=check_categorical,
1596
+ # check_index=False above, so this governs only the
1597
+ # categorical categories, whose freq goes through the
1598
+ # deprecation rather than the index's hard check
1599
+ check_freq=check_freq,
1600
+ obj=f'{obj}.iloc[:, {i}] (column name="{col}")',
1601
+ rtol=rtol,
1602
+ atol=atol,
1603
+ check_index=False,
1604
+ check_flags=False,
1605
+ )
1606
+
1607
+
1608
+ def assert_equal(left: Any, right: Any, **kwargs: Any) -> None:
1609
+ """
1610
+ Wrapper for tm.assert_*_equal to dispatch to the appropriate test function.
1611
+
1612
+ Parameters
1613
+ ----------
1614
+ left, right : Index, Series, DataFrame, ExtensionArray, or np.ndarray
1615
+ The two items to be compared.
1616
+ **kwargs
1617
+ All keyword arguments are passed through to the underlying assert method.
1618
+ """
1619
+ __tracebackhide__ = True
1620
+
1621
+ if isinstance(left, Index):
1622
+ # retain the long-standing hard freq check for datetimelike Index;
1623
+ # the check_freq deprecation in assert_index_equal only warns by
1624
+ # default. GH#51920
1625
+ if isinstance(left, (DatetimeIndex, TimedeltaIndex)):
1626
+ kwargs.setdefault("check_freq", True)
1627
+ assert_index_equal(left, right, **kwargs)
1628
+ elif isinstance(left, Series):
1629
+ assert_series_equal(left, right, **kwargs)
1630
+ elif isinstance(left, DataFrame):
1631
+ assert_frame_equal(left, right, **kwargs)
1632
+ elif isinstance(left, IntervalArray):
1633
+ assert_interval_array_equal(left, right, **kwargs)
1634
+ elif isinstance(left, PeriodArray):
1635
+ assert_period_array_equal(left, right, **kwargs)
1636
+ elif isinstance(left, DatetimeArray):
1637
+ assert_datetime_array_equal(left, right, **kwargs)
1638
+ elif isinstance(left, TimedeltaArray):
1639
+ assert_timedelta_array_equal(left, right, **kwargs)
1640
+ elif isinstance(left, ExtensionArray):
1641
+ assert_extension_array_equal(left, right, **kwargs)
1642
+ elif isinstance(left, np.ndarray):
1643
+ assert_numpy_array_equal(left, right, **kwargs)
1644
+ elif isinstance(left, str):
1645
+ assert kwargs == {}
1646
+ assert left == right
1647
+ else:
1648
+ assert kwargs == {}
1649
+ assert_almost_equal(left, right)
1650
+
1651
+
1652
+ def assert_sp_array_equal(left: Any, right: Any) -> None:
1653
+ """
1654
+ Check that the left and right SparseArray are equal.
1655
+
1656
+ Parameters
1657
+ ----------
1658
+ left : SparseArray
1659
+ right : SparseArray
1660
+ """
1661
+ _check_isinstance(left, right, pd.arrays.SparseArray)
1662
+
1663
+ assert_numpy_array_equal(left.sp_values, right.sp_values)
1664
+
1665
+ # SparseIndex comparison
1666
+ assert isinstance(left.sp_index, SparseIndex)
1667
+ assert isinstance(right.sp_index, SparseIndex)
1668
+
1669
+ left_index = left.sp_index
1670
+ right_index = right.sp_index
1671
+
1672
+ if not left_index.equals(right_index):
1673
+ raise_assert_detail(
1674
+ "SparseArray.index", "index are not equal", left_index, right_index
1675
+ )
1676
+ else:
1677
+ # Just ensure a
1678
+ pass
1679
+
1680
+ assert_attr_equal("fill_value", left, right)
1681
+ assert_attr_equal("dtype", left, right)
1682
+ assert_numpy_array_equal(left.to_dense(), right.to_dense())
1683
+
1684
+
1685
+ def assert_contains_all(iterable: Iterable[Any], dic: Container[Any]) -> None:
1686
+ for k in iterable:
1687
+ assert k in dic, f"Did not contain item: {k!r}"
1688
+
1689
+
1690
+ def assert_copy(iter1: Iterable[Any], iter2: Iterable[Any], **eql_kwargs: Any) -> None:
1691
+ """
1692
+ iter1, iter2: iterables that produce elements
1693
+ comparable with assert_almost_equal
1694
+
1695
+ Checks that the elements are equal, but not
1696
+ the same object. (Does not check that items
1697
+ in sequences are also not the same object)
1698
+ """
1699
+ for elem1, elem2 in zip(iter1, iter2, strict=True):
1700
+ assert_almost_equal(elem1, elem2, **eql_kwargs)
1701
+ msg = (
1702
+ f"Expected object {type(elem1)!r} and object {type(elem2)!r} to be "
1703
+ "different objects, but they were the same object."
1704
+ )
1705
+ assert elem1 is not elem2, msg
1706
+
1707
+
1708
+ def is_extension_array_dtype_and_needs_i8_conversion(
1709
+ left_dtype: DtypeObj, right_dtype: DtypeObj
1710
+ ) -> bool:
1711
+ """
1712
+ Checks that we have the combination of an ExtensionArraydtype and
1713
+ a dtype that should be converted to int64
1714
+
1715
+ Returns
1716
+ -------
1717
+ bool
1718
+
1719
+ Related to issue #37609
1720
+ """
1721
+ return isinstance(left_dtype, ExtensionDtype) and needs_i8_conversion(right_dtype)
1722
+
1723
+
1724
+ def assert_indexing_slices_equivalent(ser: Series, l_slc: slice, i_slc: slice) -> None:
1725
+ """
1726
+ Check that ser.iloc[i_slc] matches ser.loc[l_slc] and, if applicable,
1727
+ ser[l_slc].
1728
+ """
1729
+ expected = ser.iloc[i_slc]
1730
+
1731
+ assert_series_equal(ser.loc[l_slc], expected)
1732
+
1733
+ if not is_integer_dtype(ser.index):
1734
+ # For integer indices, .loc and plain getitem are position-based.
1735
+ assert_series_equal(ser[l_slc], expected)
1736
+
1737
+
1738
+ def assert_metadata_equivalent(
1739
+ left: DataFrame | Series, right: DataFrame | Series | None = None
1740
+ ) -> None:
1741
+ """
1742
+ Check that ._metadata attributes are equivalent.
1743
+ """
1744
+ for attr in left._metadata:
1745
+ val = getattr(left, attr, None)
1746
+ if right is None:
1747
+ assert val is None
1748
+ else:
1749
+ assert val == getattr(right, attr, None)
venv/lib/python3.14/site-packages/pandas/_testing/compat.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Helpers for sharing tests between DataFrame/Series
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ from typing import TYPE_CHECKING
8
+
9
+ from pandas import DataFrame
10
+
11
+ if TYPE_CHECKING:
12
+ from pandas._typing import DtypeObj
13
+
14
+ from pandas import Series
15
+
16
+
17
+ def get_dtype(obj: DataFrame | Series) -> DtypeObj:
18
+ if isinstance(obj, DataFrame):
19
+ # Note: we are assuming only one column
20
+ return obj.dtypes.iat[0]
21
+ else:
22
+ return obj.dtype
23
+
24
+
25
+ def get_obj(df: DataFrame, klass: type) -> DataFrame | Series:
26
+ """
27
+ For sharing tests using frame_or_series, either return the DataFrame
28
+ unchanged or return its first column as a Series.
29
+ """
30
+ if klass is DataFrame:
31
+ return df
32
+ return df._ixs(0, axis=1)
venv/lib/python3.14/site-packages/pandas/_testing/contexts.py ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from contextlib import (
4
+ AbstractContextManager,
5
+ contextmanager,
6
+ )
7
+ import os
8
+ import sys
9
+ from typing import (
10
+ IO,
11
+ TYPE_CHECKING,
12
+ Any,
13
+ )
14
+
15
+ from pandas.compat import CHAINED_WARNING_DISABLED
16
+ from pandas.errors import ChainedAssignmentError
17
+
18
+ from pandas.io.common import get_handle
19
+
20
+ if TYPE_CHECKING:
21
+ from collections.abc import Generator
22
+ import warnings
23
+
24
+ from pandas._typing import (
25
+ BaseBuffer,
26
+ CompressionOptions,
27
+ FilePath,
28
+ )
29
+
30
+
31
+ @contextmanager
32
+ def decompress_file(
33
+ path: FilePath | BaseBuffer, compression: CompressionOptions
34
+ ) -> Generator[IO[bytes]]:
35
+ """
36
+ Open a compressed file and return a file object.
37
+
38
+ Parameters
39
+ ----------
40
+ path : str
41
+ The path where the file is read from.
42
+
43
+ compression : {'gzip', 'bz2', 'zip', 'xz', 'zstd', None}
44
+ Name of the decompression to use
45
+
46
+ Returns
47
+ -------
48
+ file object
49
+ """
50
+ with get_handle(path, "rb", compression=compression, is_text=False) as handle:
51
+ yield handle.handle
52
+
53
+
54
+ @contextmanager
55
+ def set_timezone(tz: str) -> Generator[None]:
56
+ """
57
+ Context manager for temporarily setting a timezone.
58
+
59
+ Parameters
60
+ ----------
61
+ tz : str
62
+ A string representing a valid timezone.
63
+
64
+ Examples
65
+ --------
66
+ >>> from datetime import datetime
67
+ >>> from dateutil.tz import tzlocal
68
+ >>> tzlocal().tzname(datetime(2021, 1, 1)) # doctest: +SKIP
69
+ 'IST'
70
+
71
+ >>> with set_timezone("US/Eastern"):
72
+ ... tzlocal().tzname(datetime(2021, 1, 1))
73
+ 'EST'
74
+ """
75
+ import time
76
+
77
+ def setTZ(tz: str | None) -> None:
78
+ if hasattr(time, "tzset"):
79
+ if tz is None:
80
+ try:
81
+ del os.environ["TZ"]
82
+ except KeyError:
83
+ pass
84
+ else:
85
+ os.environ["TZ"] = tz
86
+ # Next line allows typing checks to pass on Windows
87
+ if sys.platform != "win32":
88
+ time.tzset()
89
+
90
+ orig_tz = os.environ.get("TZ")
91
+ setTZ(tz)
92
+ try:
93
+ yield
94
+ finally:
95
+ setTZ(orig_tz)
96
+
97
+
98
+ @contextmanager
99
+ def with_csv_dialect(name: str, **kwargs: Any) -> Generator[None]:
100
+ """
101
+ Context manager to temporarily register a CSV dialect for parsing CSV.
102
+
103
+ Parameters
104
+ ----------
105
+ name : str
106
+ The name of the dialect.
107
+ kwargs : mapping
108
+ The parameters for the dialect.
109
+
110
+ Raises
111
+ ------
112
+ ValueError : the name of the dialect conflicts with a builtin one.
113
+
114
+ See Also
115
+ --------
116
+ csv : Python's CSV library.
117
+ """
118
+ import csv
119
+
120
+ _BUILTIN_DIALECTS = {"excel", "excel-tab", "unix"}
121
+
122
+ if name in _BUILTIN_DIALECTS:
123
+ raise ValueError("Cannot override builtin dialect.")
124
+
125
+ csv.register_dialect(name, **kwargs)
126
+ try:
127
+ yield
128
+ finally:
129
+ csv.unregister_dialect(name)
130
+
131
+
132
+ def raises_chained_assignment_error(
133
+ extra_warnings: tuple[type[Warning], ...] = (),
134
+ extra_match: tuple[str | None, ...] = (),
135
+ ) -> AbstractContextManager[list[warnings.WarningMessage] | None]:
136
+ from pandas._testing import assert_produces_warning
137
+
138
+ if CHAINED_WARNING_DISABLED:
139
+ if not extra_warnings:
140
+ from contextlib import nullcontext
141
+
142
+ return nullcontext()
143
+ else:
144
+ return assert_produces_warning(
145
+ extra_warnings,
146
+ match=extra_match,
147
+ )
148
+ else:
149
+ warning = ChainedAssignmentError
150
+ match = (
151
+ "A value is being set on a copy of a DataFrame or Series "
152
+ "through chained assignment"
153
+ )
154
+ if extra_warnings:
155
+ warning = (warning, *extra_warnings) # type: ignore[assignment]
156
+ return assert_produces_warning(
157
+ warning,
158
+ match=(match, *extra_match),
159
+ )
venv/lib/python3.14/site-packages/pandas/_typing.py ADDED
@@ -0,0 +1,575 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from builtins import type as type_t # pyright: ignore[reportUnusedImport]
4
+ from collections.abc import (
5
+ Callable,
6
+ Hashable,
7
+ Iterator,
8
+ Mapping,
9
+ MutableMapping,
10
+ Sequence,
11
+ )
12
+ from datetime import (
13
+ date,
14
+ datetime,
15
+ timedelta,
16
+ tzinfo,
17
+ )
18
+ from os import PathLike
19
+ from types import EllipsisType
20
+ from typing import (
21
+ TYPE_CHECKING,
22
+ Any,
23
+ Literal,
24
+ ParamSpec,
25
+ Protocol,
26
+ SupportsIndex,
27
+ TypeAlias,
28
+ TypeVar,
29
+ Union,
30
+ overload,
31
+ )
32
+
33
+ import numpy as np
34
+ import numpy.typing as npt
35
+
36
+ # To prevent import cycles place any internal imports in the branch below
37
+ # and use a string literal forward reference to it in subsequent types
38
+ # https://mypy.readthedocs.io/en/latest/common_issues.html#import-cycles
39
+
40
+ # Note that Union is needed when a Union includes a pandas type
41
+
42
+ if TYPE_CHECKING:
43
+ from pandas._libs import (
44
+ NaTType,
45
+ Period,
46
+ Timedelta,
47
+ Timestamp,
48
+ )
49
+ from pandas._libs.tslibs import BaseOffset
50
+
51
+ from pandas.core.dtypes.dtypes import ExtensionDtype
52
+
53
+ from pandas import (
54
+ DatetimeIndex,
55
+ Interval,
56
+ PeriodIndex,
57
+ TimedeltaIndex,
58
+ )
59
+ from pandas.arrays import (
60
+ DatetimeArray,
61
+ TimedeltaArray,
62
+ )
63
+ from pandas.core.arrays.base import ExtensionArray
64
+ from pandas.core.frame import DataFrame
65
+ from pandas.core.generic import NDFrame
66
+ from pandas.core.groupby.generic import (
67
+ DataFrameGroupBy,
68
+ GroupBy,
69
+ SeriesGroupBy,
70
+ )
71
+ from pandas.core.indexes.base import Index
72
+ from pandas.core.internals import (
73
+ BlockManager,
74
+ SingleBlockManager,
75
+ )
76
+ from pandas.core.resample import Resampler
77
+ from pandas.core.series import Series
78
+ from pandas.core.window.rolling import BaseWindow
79
+
80
+ from pandas.io.formats.format import EngFormatter
81
+ from pandas.tseries.holiday import AbstractHolidayCalendar
82
+
83
+ ScalarLike_co: TypeAlias = int | float | complex | str | bytes | np.generic
84
+
85
+ # numpy compatible types
86
+ NumpyValueArrayLike: TypeAlias = ScalarLike_co | npt.ArrayLike
87
+ NumpySorter: TypeAlias = npt.NDArray[np.integer] | None
88
+
89
+
90
+ P = ParamSpec("P")
91
+
92
+ HashableT = TypeVar("HashableT", bound=Hashable)
93
+ HashableT2 = TypeVar("HashableT2", bound=Hashable)
94
+ MutableMappingT = TypeVar("MutableMappingT", bound=MutableMapping)
95
+
96
+ # array-like
97
+
98
+ ArrayLike: TypeAlias = Union["ExtensionArray", np.ndarray]
99
+ ArrayLikeT = TypeVar("ArrayLikeT", "ExtensionArray", np.ndarray)
100
+ AnyArrayLike: TypeAlias = Union[ArrayLike, "Index", "Series"]
101
+ TimeArrayLike: TypeAlias = Union["DatetimeArray", "TimedeltaArray"]
102
+
103
+ # list-like
104
+
105
+ # from https://github.com/hauntsaninja/useful_types
106
+ # includes Sequence-like objects but excludes str and bytes
107
+ _T_co = TypeVar("_T_co", covariant=True)
108
+
109
+
110
+ class SequenceNotStr(Protocol[_T_co]):
111
+ __module__: str = "pandas.api.typing.aliases"
112
+
113
+ @overload
114
+ def __getitem__(self, index: SupportsIndex, /) -> _T_co: ...
115
+
116
+ @overload
117
+ def __getitem__(self, index: slice, /) -> Sequence[_T_co]: ...
118
+
119
+ def __contains__(self, value: object, /) -> bool: ...
120
+
121
+ def __len__(self) -> int: ...
122
+
123
+ def __iter__(self) -> Iterator[_T_co]: ...
124
+
125
+ def index(self, value: Any, start: int = ..., stop: int = ..., /) -> int: ...
126
+
127
+ def count(self, value: Any, /) -> int: ...
128
+
129
+ def __reversed__(self) -> Iterator[_T_co]: ...
130
+
131
+
132
+ ListLike: TypeAlias = AnyArrayLike | SequenceNotStr | range
133
+
134
+ # scalars
135
+
136
+ PythonScalar: TypeAlias = str | float | bool
137
+ DatetimeLikeScalar: TypeAlias = Union["Period", "Timestamp", "Timedelta"]
138
+
139
+ # aligned with pandas-stubs - typical scalars found in Series. Explicitly leaves
140
+ # out object
141
+ _IndexIterScalar: TypeAlias = Union[
142
+ str,
143
+ bytes,
144
+ date,
145
+ datetime,
146
+ timedelta,
147
+ np.datetime64,
148
+ np.timedelta64,
149
+ bool,
150
+ int,
151
+ float,
152
+ "Timestamp",
153
+ "Timedelta",
154
+ ]
155
+ Scalar: TypeAlias = Union[
156
+ _IndexIterScalar, "Interval", complex, np.integer, np.floating, np.complexfloating
157
+ ]
158
+
159
+ IntStrT = TypeVar("IntStrT", bound=int | str)
160
+
161
+ # timestamp and timedelta convertible types
162
+
163
+ TimestampConvertibleTypes: TypeAlias = Union[
164
+ "Timestamp", date, np.datetime64, np.int64, float, str
165
+ ]
166
+ TimestampNonexistent: TypeAlias = (
167
+ Literal["shift_forward", "shift_backward", "NaT", "raise"] | timedelta
168
+ )
169
+
170
+ TimedeltaConvertibleTypes: TypeAlias = Union[
171
+ "Timedelta", timedelta, np.timedelta64, np.int64, float, str
172
+ ]
173
+ Timezone: TypeAlias = str | tzinfo
174
+
175
+ ToTimestampHow: TypeAlias = Literal["s", "e", "start", "end"]
176
+
177
+ # NDFrameT is stricter and ensures that the same subclass of NDFrame always is
178
+ # used. E.g. `def func(a: NDFrameT) -> NDFrameT: ...` means that if a
179
+ # Series is passed into a function, a Series is always returned and if a DataFrame is
180
+ # passed in, a DataFrame is always returned.
181
+ NDFrameT = TypeVar("NDFrameT", bound="NDFrame")
182
+
183
+ IndexT = TypeVar("IndexT", bound="Index")
184
+ FreqIndexT = TypeVar("FreqIndexT", "DatetimeIndex", "PeriodIndex", "TimedeltaIndex")
185
+ NumpyIndexT = TypeVar("NumpyIndexT", np.ndarray, "Index")
186
+
187
+ AxisInt: TypeAlias = int
188
+ Axis: TypeAlias = AxisInt | Literal["index", "columns", "rows"]
189
+ IndexLabel: TypeAlias = Hashable | Sequence[Hashable]
190
+ Level: TypeAlias = Hashable
191
+ Shape: TypeAlias = tuple[int, ...]
192
+ Suffixes: TypeAlias = Sequence[str | None]
193
+ Ordered: TypeAlias = bool | None
194
+ JSONSerializable: TypeAlias = PythonScalar | list | dict | None
195
+ Frequency: TypeAlias = Union[str, "BaseOffset"]
196
+ Axes: TypeAlias = ListLike
197
+
198
+ RandomState: TypeAlias = (
199
+ int
200
+ | np.ndarray
201
+ | np.random.Generator
202
+ | np.random.BitGenerator
203
+ | np.random.RandomState
204
+ )
205
+
206
+
207
+ # dtypes
208
+ NpDtype: TypeAlias = str | np.dtype | type[str | complex | bool | object]
209
+ Dtype: TypeAlias = Union["ExtensionDtype", NpDtype]
210
+ AstypeArg: TypeAlias = Union["ExtensionDtype", npt.DTypeLike]
211
+ # DtypeArg specifies all allowable dtypes in a functions its dtype argument
212
+ DtypeArg: TypeAlias = Dtype | Mapping[Hashable, Dtype]
213
+ DtypeObj: TypeAlias = Union[np.dtype, "ExtensionDtype"]
214
+
215
+ # converters
216
+ ConvertersArg: TypeAlias = dict[Hashable, Callable[[Dtype], Dtype]]
217
+
218
+ # parse_dates
219
+ ParseDatesArg: TypeAlias = (
220
+ bool | list[Hashable] | list[list[Hashable]] | dict[Hashable, list[Hashable]]
221
+ )
222
+
223
+ # For functions like rename that convert one label to another
224
+ Renamer: TypeAlias = Mapping[Any, Hashable] | Callable[[Any], Hashable]
225
+
226
+ # to maintain type information across generic functions and parametrization
227
+ T = TypeVar("T")
228
+
229
+ # used in decorators to preserve the signature of the function it decorates
230
+ # see https://mypy.readthedocs.io/en/stable/generics.html#declaring-decorators
231
+ FuncType: TypeAlias = Callable[..., Any]
232
+ F = TypeVar("F", bound=FuncType)
233
+ TypeT = TypeVar("TypeT", bound=type)
234
+
235
+ # types of vectorized key functions for DataFrame::sort_values and
236
+ # DataFrame::sort_index, among others
237
+ ValueKeyFunc: TypeAlias = Callable[["Series"], Union["Series", AnyArrayLike]] | None
238
+ IndexKeyFunc: TypeAlias = Callable[["Index"], Union["Index", AnyArrayLike]] | None
239
+
240
+ # types of `func` kwarg for DataFrame.aggregate and Series.aggregate
241
+ AggFuncTypeBase: TypeAlias = Callable | str
242
+ AggFuncTypeDict: TypeAlias = MutableMapping[
243
+ Hashable, AggFuncTypeBase | list[AggFuncTypeBase]
244
+ ]
245
+ AggFuncType: TypeAlias = AggFuncTypeBase | list[AggFuncTypeBase] | AggFuncTypeDict
246
+ AggObjType: TypeAlias = Union[
247
+ "Series",
248
+ "DataFrame",
249
+ "GroupBy",
250
+ "SeriesGroupBy",
251
+ "DataFrameGroupBy",
252
+ "BaseWindow",
253
+ "Resampler",
254
+ ]
255
+
256
+ PythonFuncType: TypeAlias = Callable[[Any], Any]
257
+
258
+ # filenames and file-like-objects
259
+ AnyStr_co = TypeVar("AnyStr_co", str, bytes, covariant=True)
260
+ AnyStr_contra = TypeVar("AnyStr_contra", str, bytes, contravariant=True)
261
+
262
+
263
+ class BaseBuffer(Protocol):
264
+ def seek(self, offset: int, whence: int = ..., /) -> int:
265
+ # with one argument: gzip.GzipFile, bz2.BZ2File
266
+ # with two arguments: zip.ZipFile, read_sas
267
+ ...
268
+
269
+ def seekable(self) -> bool:
270
+ # for bz2.BZ2File
271
+ ...
272
+
273
+ def tell(self) -> int:
274
+ # for zip.ZipFile, read_stata, to_stata
275
+ ...
276
+
277
+
278
+ class ReadBuffer(BaseBuffer, Protocol[AnyStr_co]):
279
+ __module__: str = "pandas.api.typing.aliases"
280
+
281
+ def read(self, n: int = ..., /) -> AnyStr_co:
282
+ # for BytesIOWrapper, gzip.GzipFile, bz2.BZ2File
283
+ ...
284
+
285
+
286
+ class WriteBuffer(BaseBuffer, Protocol[AnyStr_contra]):
287
+ __module__: str = "pandas.api.typing.aliases"
288
+
289
+ def write(self, b: AnyStr_contra, /) -> Any:
290
+ # for gzip.GzipFile, bz2.BZ2File
291
+ ...
292
+
293
+ def flush(self) -> Any:
294
+ # for gzip.GzipFile, bz2.BZ2File
295
+ ...
296
+
297
+
298
+ class ReadPickleBuffer(ReadBuffer[bytes], Protocol):
299
+ __module__: str = "pandas.api.typing.aliases"
300
+
301
+ def readline(self) -> bytes: ...
302
+
303
+
304
+ class WriteExcelBuffer(WriteBuffer[bytes], Protocol):
305
+ __module__: str = "pandas.api.typing.aliases"
306
+
307
+ def truncate(self, size: int | None = ..., /) -> int: ...
308
+
309
+
310
+ class ReadCsvBuffer(ReadBuffer[AnyStr_co], Protocol):
311
+ __module__: str = "pandas.api.typing.aliases"
312
+
313
+ def __iter__(self) -> Iterator[AnyStr_co]:
314
+ # for engine=python
315
+ ...
316
+
317
+ def fileno(self) -> int:
318
+ # for _MMapWrapper
319
+ ...
320
+
321
+ def readline(self) -> AnyStr_co:
322
+ # for engine=python
323
+ ...
324
+
325
+ @property
326
+ def closed(self) -> bool:
327
+ # for engine=pyarrow
328
+ ...
329
+
330
+
331
+ FilePath: TypeAlias = str | PathLike[str]
332
+
333
+ # for arbitrary kwargs passed during reading/writing files
334
+ StorageOptions: TypeAlias = dict[str, Any] | None
335
+
336
+ # compression keywords and compression
337
+ CompressionDict: TypeAlias = dict[str, Any]
338
+ CompressionOptions: TypeAlias = (
339
+ Literal["infer", "gzip", "bz2", "zip", "xz", "zstd", "tar"] | CompressionDict | None
340
+ )
341
+ ParquetCompressionOptions: TypeAlias = (
342
+ Literal["snappy", "gzip", "brotli", "lz4", "zstd"] | None
343
+ )
344
+
345
+ # types in DataFrameFormatter
346
+ FormattersType: TypeAlias = (
347
+ list[Callable] | tuple[Callable, ...] | Mapping[str | int, Callable]
348
+ )
349
+ ColspaceType: TypeAlias = Mapping[Hashable, str | int]
350
+ FloatFormatType: TypeAlias = Union[str, Callable, "EngFormatter"]
351
+ ColspaceArgType: TypeAlias = (
352
+ str | int | Sequence[str | int] | Mapping[Hashable, str | int]
353
+ )
354
+
355
+ # Arguments for fillna()
356
+ FillnaOptions: TypeAlias = Literal["backfill", "bfill", "ffill", "pad"]
357
+ InterpolateOptions: TypeAlias = Literal[
358
+ "linear",
359
+ "time",
360
+ "index",
361
+ "values",
362
+ "nearest",
363
+ "zero",
364
+ "slinear",
365
+ "quadratic",
366
+ "cubic",
367
+ "barycentric",
368
+ "polynomial",
369
+ "krogh",
370
+ "piecewise_polynomial",
371
+ "spline",
372
+ "pchip",
373
+ "akima",
374
+ "cubicspline",
375
+ "from_derivatives",
376
+ ]
377
+
378
+ # internals
379
+ Manager: TypeAlias = Union["BlockManager", "SingleBlockManager"]
380
+
381
+ # indexing
382
+ # PositionalIndexer -> valid 1D positional indexer, e.g. can pass
383
+ # to ndarray.__getitem__
384
+ # ScalarIndexer is for a single value as the index
385
+ # SequenceIndexer is for list like or slices (but not tuples)
386
+ # PositionalIndexerTuple is extends the PositionalIndexer for 2D arrays
387
+ # These are used in various __getitem__ overloads
388
+ # Using List[int] here rather than Sequence[int] to disallow tuples.
389
+ ScalarIndexer: TypeAlias = int | np.integer
390
+ SequenceIndexer: TypeAlias = slice | EllipsisType | list[int] | np.ndarray
391
+ PositionalIndexer: TypeAlias = ScalarIndexer | SequenceIndexer
392
+ PositionalIndexerTuple: TypeAlias = tuple[PositionalIndexer, PositionalIndexer]
393
+ PositionalIndexer2D: TypeAlias = PositionalIndexer | PositionalIndexerTuple
394
+ TakeIndexer: TypeAlias = Sequence[int] | Sequence[np.integer] | npt.NDArray[np.integer]
395
+
396
+ # Shared by functions such as drop and astype
397
+ IgnoreRaise: TypeAlias = Literal["ignore", "raise"]
398
+
399
+ # Windowing rank methods
400
+ WindowingRankType: TypeAlias = Literal["average", "min", "max"]
401
+
402
+ # rank tie-breaking methods (Series.rank / DataFrame.rank / GroupBy.rank)
403
+ RankMethod: TypeAlias = Literal["average", "min", "max", "first", "dense"]
404
+ RankNaOption: TypeAlias = Literal["keep", "top", "bottom"]
405
+
406
+ # read_csv engines
407
+ CSVEngine: TypeAlias = Literal["c", "python", "pyarrow", "python-fwf"]
408
+
409
+ # read_json engines
410
+ JSONEngine: TypeAlias = Literal["ujson", "pyarrow"]
411
+
412
+ # read_xml parsers
413
+ XMLParsers: TypeAlias = Literal["lxml", "etree"]
414
+
415
+ # read_html flavors
416
+ HTMLFlavors: TypeAlias = Literal["lxml", "html5lib", "bs4"]
417
+
418
+ # Interval closed type
419
+ IntervalLeftRight: TypeAlias = Literal["left", "right"]
420
+ IntervalClosedType: TypeAlias = IntervalLeftRight | Literal["both", "neither"]
421
+
422
+ # datetime and NaTType
423
+ DatetimeNaTType: TypeAlias = Union[datetime, "NaTType"]
424
+ DateTimeErrorChoices: TypeAlias = Literal["raise", "coerce"]
425
+
426
+ # sort_index
427
+ SortKind: TypeAlias = Literal["quicksort", "mergesort", "heapsort", "stable"]
428
+ NaPosition: TypeAlias = Literal["first", "last"]
429
+
430
+ # Arguments for nsmallest and nlargest
431
+ NsmallestNlargestKeep: TypeAlias = Literal["first", "last", "all"]
432
+
433
+ # quantile interpolation
434
+ QuantileInterpolation: TypeAlias = Literal[
435
+ "linear", "lower", "higher", "midpoint", "nearest"
436
+ ]
437
+
438
+ # plotting
439
+ PlottingOrientation: TypeAlias = Literal["horizontal", "vertical"]
440
+
441
+ # dropna
442
+ AnyAll: TypeAlias = Literal["any", "all"]
443
+
444
+ # merge
445
+ MergeHow: TypeAlias = Literal[
446
+ "left", "right", "inner", "outer", "cross", "left_anti", "right_anti"
447
+ ]
448
+ MergeValidate: TypeAlias = Literal[
449
+ "one_to_one",
450
+ "1:1",
451
+ "one_to_many",
452
+ "1:m",
453
+ "many_to_one",
454
+ "m:1",
455
+ "many_to_many",
456
+ "m:m",
457
+ ]
458
+
459
+ # join
460
+ JoinHow: TypeAlias = Literal["left", "right", "inner", "outer"]
461
+ JoinValidate: TypeAlias = Literal[
462
+ "one_to_one",
463
+ "1:1",
464
+ "one_to_many",
465
+ "1:m",
466
+ "many_to_one",
467
+ "m:1",
468
+ "many_to_many",
469
+ "m:m",
470
+ ]
471
+
472
+ # reindex
473
+ ReindexMethod: TypeAlias = FillnaOptions | Literal["nearest"]
474
+
475
+ MatplotlibColor: TypeAlias = str | Sequence[float]
476
+ TimeGrouperOrigin: TypeAlias = Union[
477
+ "Timestamp", Literal["epoch", "start", "start_day", "end", "end_day"]
478
+ ]
479
+ TimeAmbiguous: TypeAlias = (
480
+ Literal["infer", "NaT", "raise"] | bool | npt.NDArray[np.bool_]
481
+ )
482
+ TimeNonexistent: TypeAlias = (
483
+ Literal["shift_forward", "shift_backward", "NaT", "raise"] | timedelta
484
+ )
485
+
486
+ DropKeep: TypeAlias = Literal["first", "last", False]
487
+ CorrelationMethod: TypeAlias = (
488
+ Literal["pearson", "kendall", "spearman"]
489
+ | Callable[[np.ndarray, np.ndarray], float]
490
+ )
491
+
492
+ AlignJoin: TypeAlias = Literal["outer", "inner", "left", "right"]
493
+ DtypeBackend: TypeAlias = Literal["pyarrow", "numpy_nullable"]
494
+
495
+ TimeUnit: TypeAlias = Literal["s", "ms", "us", "ns"]
496
+ OpenFileErrors: TypeAlias = Literal[
497
+ "strict",
498
+ "ignore",
499
+ "replace",
500
+ "surrogateescape",
501
+ "xmlcharrefreplace",
502
+ "backslashreplace",
503
+ "namereplace",
504
+ ]
505
+
506
+ # update
507
+ UpdateJoin: TypeAlias = Literal["left"]
508
+
509
+ # applymap
510
+ NaAction: TypeAlias = Literal["ignore"]
511
+
512
+ # from_dict
513
+ FromDictOrient: TypeAlias = Literal["columns", "index", "tight"]
514
+
515
+ # to_stata
516
+ ToStataByteorder: TypeAlias = Literal[">", "<", "little", "big"]
517
+
518
+ # ExcelWriter
519
+ ExcelWriterIfSheetExists: TypeAlias = Literal["error", "new", "replace", "overlay"]
520
+ ExcelWriterMergeCells: TypeAlias = bool | Literal["columns"]
521
+
522
+ # Offsets
523
+ OffsetCalendar: TypeAlias = Union[np.busdaycalendar, "AbstractHolidayCalendar"]
524
+
525
+ # read_csv: usecols
526
+ UsecolsArgType: TypeAlias = (
527
+ SequenceNotStr[Hashable] | range | AnyArrayLike | Callable[[HashableT], bool] | None
528
+ )
529
+
530
+ # maintain the sub-type of any hashable sequence
531
+ SequenceT = TypeVar("SequenceT", bound=Sequence[Hashable])
532
+
533
+ SliceType: TypeAlias = Hashable | None
534
+
535
+
536
+ # Arrow PyCapsule Interface
537
+ # from https://arrow.apache.org/docs/format/CDataInterface/PyCapsuleInterface.html#protocol-typehints
538
+
539
+
540
+ class ArrowArrayExportable(Protocol):
541
+ """
542
+ An object with an ``__arrow_c_array__`` method.
543
+
544
+ This method indicates the object is an Arrow-compatible object implementing
545
+ the `Arrow PyCapsule Protocol`_ (exposing the `Arrow C Data Interface`_ in
546
+ Python), enabling zero-copy Arrow data interchange across libraries.
547
+
548
+ .. _Arrow PyCapsule Protocol: https://arrow.apache.org/docs/format/CDataInterface/PyCapsuleInterface.html
549
+ .. _Arrow C Data Interface: https://arrow.apache.org/docs/format/CDataInterface.html
550
+
551
+ """
552
+
553
+ def __arrow_c_array__(
554
+ self, requested_schema: object | None = None
555
+ ) -> tuple[object, object]: ...
556
+
557
+
558
+ class ArrowStreamExportable(Protocol):
559
+ """
560
+ An object with an ``__arrow_c_stream__`` method.
561
+
562
+ This method indicates the object is an Arrow-compatible object implementing
563
+ the `Arrow PyCapsule Protocol`_ (exposing the `Arrow C Data Interface`_
564
+ for streams in Python), enabling zero-copy Arrow data interchange across
565
+ libraries.
566
+
567
+ .. _Arrow PyCapsule Protocol: https://arrow.apache.org/docs/format/CDataInterface/PyCapsuleInterface.html
568
+ .. _Arrow C Stream Interface: https://arrow.apache.org/docs/format/CStreamInterface.html
569
+
570
+ """
571
+
572
+ def __arrow_c_stream__(self, requested_schema: object | None = None) -> object: ...
573
+
574
+
575
+ __all__ = ["type_t"]
venv/lib/python3.14/site-packages/pandas/_version_meson.py ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ __version__="3.1.1"
2
+ __git_version__="3dcc6fbbbebc5e85dd3e83fe49b382ca7735cae1"
venv/lib/python3.14/site-packages/pandas/api/__init__.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """public toolkit API"""
2
+
3
+ from pandas.api import (
4
+ executors,
5
+ extensions,
6
+ indexers,
7
+ interchange,
8
+ internals,
9
+ types,
10
+ typing,
11
+ )
12
+
13
+ __all__ = [
14
+ "executors",
15
+ "extensions",
16
+ "indexers",
17
+ "interchange",
18
+ "internals",
19
+ "types",
20
+ "typing",
21
+ ]
venv/lib/python3.14/site-packages/pandas/api/executors/__init__.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ """
2
+ Public API for function executor engines to be used with ``map`` and ``apply``.
3
+ """
4
+
5
+ from pandas.core.apply import BaseExecutionEngine
6
+
7
+ __all__ = ["BaseExecutionEngine"]
venv/lib/python3.14/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
+ "ExtensionArray",
25
+ "ExtensionDtype",
26
+ "ExtensionScalarOpsMixin",
27
+ "no_default",
28
+ "register_dataframe_accessor",
29
+ "register_extension_dtype",
30
+ "register_index_accessor",
31
+ "register_series_accessor",
32
+ "take",
33
+ ]
venv/lib/python3.14/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
+ "BaseIndexer",
14
+ "FixedForwardWindowIndexer",
15
+ "VariableOffsetWindowIndexer",
16
+ "check_array_indexer",
17
+ ]
venv/lib/python3.14/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__ = ["DataFrame", "from_dataframe"]
venv/lib/python3.14/site-packages/pandas/api/internals.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+
3
+ from pandas._typing import ArrayLike
4
+
5
+ from pandas import (
6
+ DataFrame,
7
+ Index,
8
+ )
9
+ from pandas.core.internals.api import _make_block
10
+ from pandas.core.internals.managers import BlockManager as _BlockManager
11
+
12
+
13
+ def create_dataframe_from_blocks(
14
+ blocks: list[tuple[ArrayLike, np.ndarray]], index: Index, columns: Index
15
+ ) -> DataFrame:
16
+ """
17
+ Low-level function to create a DataFrame from arrays as they are
18
+ representing the block structure of the resulting DataFrame.
19
+
20
+ Attention: this is an advanced, low-level function that should only be
21
+ used if you know that the below-mentioned assumptions are guaranteed.
22
+ If passing data that do not follow those assumptions, subsequent
23
+ operations on the resulting DataFrame might lead to strange errors.
24
+ For almost all use cases, you should use the standard pd.DataFrame(..)
25
+ constructor instead. If you are planning to use this function, let us
26
+ know by opening an issue at https://github.com/pandas-dev/pandas/issues.
27
+
28
+ Assumptions:
29
+
30
+ - The block arrays are either a 2D numpy array or a pandas ExtensionArray
31
+ - In case of a numpy array, it is assumed to already be in the expected
32
+ shape for Blocks (2D, (cols, rows), i.e. transposed compared to the
33
+ DataFrame columns).
34
+ - All arrays are taken as is (no type inference) and expected to have the
35
+ correct size.
36
+ - The placement arrays have the correct length (equalling the number of
37
+ columns that its equivalent block array represents), and all placement
38
+ arrays together form a complete set of 0 to n_columns - 1.
39
+
40
+ Parameters
41
+ ----------
42
+ blocks : list of tuples of (block_array, block_placement)
43
+ This should be a list of tuples existing of (block_array, block_placement),
44
+ where:
45
+
46
+ - block_array is a 2D numpy array or a 1D ExtensionArray, following the
47
+ requirements listed above.
48
+ - block_placement is a 1D integer numpy array
49
+ index : Index
50
+ The Index object for the `index` of the resulting DataFrame.
51
+ columns : Index
52
+ The Index object for the `columns` of the resulting DataFrame.
53
+
54
+ Returns
55
+ -------
56
+ DataFrame
57
+ """
58
+ block_objs = [_make_block(*block) for block in blocks]
59
+ axes = [columns, index]
60
+ mgr = _BlockManager(block_objs, axes)
61
+ return DataFrame._from_mgr(mgr, mgr.axes)
venv/lib/python3.14/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
+ "CategoricalDtype",
18
+ "DatetimeTZDtype",
19
+ "IntervalDtype",
20
+ "PeriodDtype",
21
+ "infer_dtype",
22
+ "union_categoricals",
23
+ ]
venv/lib/python3.14/site-packages/pandas/api/typing/__init__.py ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Public API classes that store intermediate results useful for type-hinting.
3
+ """
4
+
5
+ from typing import TYPE_CHECKING
6
+
7
+ from pandas._libs import NaTType
8
+ from pandas._libs.lib import NoDefault
9
+ from pandas._libs.missing import NAType
10
+
11
+ from pandas.core.col import Expression
12
+ from pandas.core.groupby import (
13
+ DataFrameGroupBy,
14
+ SeriesGroupBy,
15
+ )
16
+ from pandas.core.indexes.frozen import FrozenList
17
+ from pandas.core.resample import (
18
+ DatetimeIndexResamplerGroupBy,
19
+ PeriodIndexResamplerGroupBy,
20
+ Resampler,
21
+ TimedeltaIndexResamplerGroupBy,
22
+ TimeGrouper,
23
+ )
24
+ from pandas.core.window import (
25
+ Expanding,
26
+ ExpandingGroupBy,
27
+ ExponentialMovingWindow,
28
+ ExponentialMovingWindowGroupBy,
29
+ Rolling,
30
+ RollingGroupBy,
31
+ Window,
32
+ )
33
+
34
+ # TODO: Can't import Styler without importing jinja2
35
+ # from pandas.io.formats.style import Styler
36
+ from pandas.io.json._json import JsonReader
37
+ from pandas.io.sas.sasreader import SASReader
38
+ from pandas.io.stata import StataReader
39
+
40
+ __all__ = [
41
+ "DataFrameGroupBy",
42
+ "DatetimeIndexResamplerGroupBy",
43
+ "Expanding",
44
+ "ExpandingGroupBy",
45
+ "ExponentialMovingWindow",
46
+ "ExponentialMovingWindowGroupBy",
47
+ "Expression",
48
+ "FrozenList",
49
+ "JsonReader",
50
+ "NAType",
51
+ "NaTType",
52
+ "NoDefault",
53
+ "PeriodIndexResamplerGroupBy",
54
+ "Resampler",
55
+ "Rolling",
56
+ "RollingGroupBy",
57
+ "SASReader",
58
+ "SeriesGroupBy",
59
+ "StataReader",
60
+ "TimeGrouper",
61
+ "TimedeltaIndexResamplerGroupBy",
62
+ "Window",
63
+ ]
64
+
65
+
66
+ if TYPE_CHECKING:
67
+ # GH#49578 this module exists for type-hinting, so annotating with a
68
+ # deprecated spelling has to keep working until it is removed. Binding these
69
+ # unconditionally would instead put them back in the public namespace.
70
+ DatetimeIndexResamplerGroupby = DatetimeIndexResamplerGroupBy
71
+ ExpandingGroupby = ExpandingGroupBy
72
+ ExponentialMovingWindowGroupby = ExponentialMovingWindowGroupBy
73
+ PeriodIndexResamplerGroupby = PeriodIndexResamplerGroupBy
74
+ RollingGroupby = RollingGroupBy
75
+ TimedeltaIndexResamplerGroupby = TimedeltaIndexResamplerGroupBy
76
+ else:
77
+ # would otherwise land in the public namespace; see test_api_typing
78
+ del TYPE_CHECKING
79
+
80
+ def __getattr__(name: str) -> object:
81
+ deprecated = {
82
+ "DatetimeIndexResamplerGroupby": DatetimeIndexResamplerGroupBy,
83
+ "ExpandingGroupby": ExpandingGroupBy,
84
+ "ExponentialMovingWindowGroupby": ExponentialMovingWindowGroupBy,
85
+ "PeriodIndexResamplerGroupby": PeriodIndexResamplerGroupBy,
86
+ "RollingGroupby": RollingGroupBy,
87
+ "TimedeltaIndexResamplerGroupby": TimedeltaIndexResamplerGroupBy,
88
+ }
89
+ if name in deprecated:
90
+ # imported here rather than at module level, which would expose
91
+ # them as pandas.api.typing attributes
92
+ import warnings
93
+
94
+ from pandas.errors import Pandas4Warning
95
+
96
+ new = deprecated[name]
97
+ warnings.warn(
98
+ f"pandas.api.typing.{name} is deprecated and will be removed in "
99
+ f"a future version. Use pandas.api.typing.{new.__name__} instead.",
100
+ Pandas4Warning,
101
+ stacklevel=2,
102
+ )
103
+ return new
104
+ raise AttributeError(f"module 'pandas.api.typing' has no attribute '{name}'")
venv/lib/python3.14/site-packages/pandas/api/typing/aliases.py ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pandas._typing import (
2
+ AggFuncType,
3
+ AlignJoin,
4
+ AnyAll,
5
+ AnyArrayLike,
6
+ ArrayLike,
7
+ AstypeArg,
8
+ Axes,
9
+ Axis,
10
+ ColspaceArgType,
11
+ CompressionOptions,
12
+ CorrelationMethod,
13
+ CSVEngine,
14
+ DropKeep,
15
+ Dtype,
16
+ DtypeArg,
17
+ DtypeBackend,
18
+ DtypeObj,
19
+ ExcelWriterIfSheetExists,
20
+ ExcelWriterMergeCells,
21
+ FilePath,
22
+ FillnaOptions,
23
+ FloatFormatType,
24
+ FormattersType,
25
+ FromDictOrient,
26
+ HTMLFlavors,
27
+ IgnoreRaise,
28
+ IndexLabel,
29
+ InterpolateOptions,
30
+ IntervalClosedType,
31
+ IntervalLeftRight,
32
+ JoinHow,
33
+ JoinValidate,
34
+ JSONEngine,
35
+ JSONSerializable,
36
+ ListLike,
37
+ MergeHow,
38
+ MergeValidate,
39
+ NaPosition,
40
+ NsmallestNlargestKeep,
41
+ OpenFileErrors,
42
+ Ordered,
43
+ ParquetCompressionOptions,
44
+ QuantileInterpolation,
45
+ ReadBuffer,
46
+ ReadCsvBuffer,
47
+ ReadPickleBuffer,
48
+ ReindexMethod,
49
+ Scalar,
50
+ ScalarIndexer,
51
+ SequenceIndexer,
52
+ SequenceNotStr,
53
+ SliceType,
54
+ SortKind,
55
+ StorageOptions,
56
+ Suffixes,
57
+ TakeIndexer,
58
+ TimeAmbiguous,
59
+ TimedeltaConvertibleTypes,
60
+ TimeGrouperOrigin,
61
+ TimeNonexistent,
62
+ TimestampConvertibleTypes,
63
+ TimeUnit,
64
+ ToStataByteorder,
65
+ ToTimestampHow,
66
+ UpdateJoin,
67
+ UsecolsArgType,
68
+ WindowingRankType,
69
+ WriteBuffer,
70
+ WriteExcelBuffer,
71
+ XMLParsers,
72
+ )
73
+
74
+ __all__ = [
75
+ "AggFuncType",
76
+ "AlignJoin",
77
+ "AnyAll",
78
+ "AnyArrayLike",
79
+ "ArrayLike",
80
+ "AstypeArg",
81
+ "Axes",
82
+ "Axis",
83
+ "CSVEngine",
84
+ "ColspaceArgType",
85
+ "CompressionOptions",
86
+ "CorrelationMethod",
87
+ "DropKeep",
88
+ "Dtype",
89
+ "DtypeArg",
90
+ "DtypeBackend",
91
+ "DtypeObj",
92
+ "ExcelWriterIfSheetExists",
93
+ "ExcelWriterMergeCells",
94
+ "FilePath",
95
+ "FillnaOptions",
96
+ "FloatFormatType",
97
+ "FormattersType",
98
+ "FromDictOrient",
99
+ "HTMLFlavors",
100
+ "IgnoreRaise",
101
+ "IndexLabel",
102
+ "InterpolateOptions",
103
+ "IntervalClosedType",
104
+ "IntervalLeftRight",
105
+ "JSONEngine",
106
+ "JSONSerializable",
107
+ "JoinHow",
108
+ "JoinValidate",
109
+ "ListLike",
110
+ "MergeHow",
111
+ "MergeValidate",
112
+ "NaPosition",
113
+ "NsmallestNlargestKeep",
114
+ "OpenFileErrors",
115
+ "Ordered",
116
+ "ParquetCompressionOptions",
117
+ "QuantileInterpolation",
118
+ "ReadBuffer",
119
+ "ReadCsvBuffer",
120
+ "ReadPickleBuffer",
121
+ "ReindexMethod",
122
+ "Scalar",
123
+ "ScalarIndexer",
124
+ "SequenceIndexer",
125
+ "SequenceNotStr",
126
+ "SliceType",
127
+ "SortKind",
128
+ "StorageOptions",
129
+ "Suffixes",
130
+ "TakeIndexer",
131
+ "TimeAmbiguous",
132
+ "TimeGrouperOrigin",
133
+ "TimeNonexistent",
134
+ "TimeUnit",
135
+ "TimedeltaConvertibleTypes",
136
+ "TimestampConvertibleTypes",
137
+ "ToStataByteorder",
138
+ "ToTimestampHow",
139
+ "UpdateJoin",
140
+ "UsecolsArgType",
141
+ "WindowingRankType",
142
+ "WriteBuffer",
143
+ "WriteExcelBuffer",
144
+ "XMLParsers",
145
+ ]
venv/lib/python3.14/site-packages/pandas/arrays/__init__.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ All of pandas' ExtensionArrays.
3
+
4
+ See :ref:`extending.extension-types` for more.
5
+ """
6
+
7
+ from pandas.core.arrays import (
8
+ ArrowExtensionArray,
9
+ ArrowStringArray,
10
+ BooleanArray,
11
+ Categorical,
12
+ DatetimeArray,
13
+ FloatingArray,
14
+ IntegerArray,
15
+ IntervalArray,
16
+ NumpyExtensionArray,
17
+ PeriodArray,
18
+ SparseArray,
19
+ StringArray,
20
+ TimedeltaArray,
21
+ )
22
+
23
+ __all__ = [
24
+ "ArrowExtensionArray",
25
+ "ArrowStringArray",
26
+ "BooleanArray",
27
+ "Categorical",
28
+ "DatetimeArray",
29
+ "FloatingArray",
30
+ "IntegerArray",
31
+ "IntervalArray",
32
+ "NumpyExtensionArray",
33
+ "PeriodArray",
34
+ "SparseArray",
35
+ "StringArray",
36
+ "TimedeltaArray",
37
+ ]
venv/lib/python3.14/site-packages/pandas/compat/__init__.py ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ compat
3
+ ======
4
+
5
+ Cross-compatible functions for different versions of Python.
6
+
7
+ Other items:
8
+ * platform checker
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ import platform
14
+ import sys
15
+ from typing import TYPE_CHECKING
16
+
17
+ from pandas.compat._constants import (
18
+ CHAINED_WARNING_DISABLED,
19
+ IS64,
20
+ ISMUSL,
21
+ PY312,
22
+ PY313,
23
+ PY314,
24
+ PY315,
25
+ PYPY,
26
+ WASM,
27
+ )
28
+ from pandas.compat.numpy import is_numpy_dev
29
+ from pandas.compat.pyarrow import (
30
+ HAS_PYARROW,
31
+ PYARROW_INSTALLED,
32
+ PYARROW_MIN_VERSION,
33
+ pa_version_under17p0,
34
+ pa_version_under18p0,
35
+ pa_version_under19p0,
36
+ pa_version_under20p0,
37
+ pa_version_under21p0,
38
+ pa_version_under22p0,
39
+ pa_version_under23p0,
40
+ pa_version_under25p0,
41
+ pa_version_under26p0,
42
+ )
43
+
44
+ if TYPE_CHECKING:
45
+ from pandas._typing import F
46
+
47
+
48
+ def set_function_name(f: F, name: str, cls: type) -> F:
49
+ """
50
+ Bind the name/qualname attributes of the function.
51
+ """
52
+ f.__name__ = name
53
+ f.__qualname__ = f"{cls.__name__}.{name}"
54
+ f.__module__ = cls.__module__
55
+ return f
56
+
57
+
58
+ def is_platform_little_endian() -> bool:
59
+ """
60
+ Checking if the running platform is little endian.
61
+
62
+ Returns
63
+ -------
64
+ bool
65
+ True if the running platform is little endian.
66
+ """
67
+ return sys.byteorder == "little"
68
+
69
+
70
+ def is_platform_windows() -> bool:
71
+ """
72
+ Checking if the running platform is windows.
73
+
74
+ Returns
75
+ -------
76
+ bool
77
+ True if the running platform is windows.
78
+ """
79
+ return sys.platform in ["win32", "cygwin"]
80
+
81
+
82
+ def is_platform_linux() -> bool:
83
+ """
84
+ Checking if the running platform is linux.
85
+
86
+ Returns
87
+ -------
88
+ bool
89
+ True if the running platform is linux.
90
+ """
91
+ return sys.platform == "linux"
92
+
93
+
94
+ def is_platform_mac() -> bool:
95
+ """
96
+ Checking if the running platform is mac.
97
+
98
+ Returns
99
+ -------
100
+ bool
101
+ True if the running platform is mac.
102
+ """
103
+ return sys.platform == "darwin"
104
+
105
+
106
+ def is_platform_arm() -> bool:
107
+ """
108
+ Checking if the running platform use ARM architecture.
109
+
110
+ Returns
111
+ -------
112
+ bool
113
+ True if the running platform uses ARM architecture.
114
+ """
115
+ return platform.machine() in ("arm64", "aarch64") or platform.machine().startswith(
116
+ "armv"
117
+ )
118
+
119
+
120
+ def is_platform_power() -> bool:
121
+ """
122
+ Checking if the running platform use Power architecture.
123
+
124
+ Returns
125
+ -------
126
+ bool
127
+ True if the running platform uses ARM architecture.
128
+ """
129
+ return platform.machine() in ("ppc64", "ppc64le")
130
+
131
+
132
+ def is_platform_riscv64() -> bool:
133
+ """
134
+ Checking if the running platform use riscv64 architecture.
135
+
136
+ Returns
137
+ -------
138
+ bool
139
+ True if the running platform uses riscv64 architecture.
140
+ """
141
+ return platform.machine() == "riscv64"
142
+
143
+
144
+ __all__ = [
145
+ "CHAINED_WARNING_DISABLED",
146
+ "HAS_PYARROW",
147
+ "IS64",
148
+ "ISMUSL",
149
+ "PY312",
150
+ "PY313",
151
+ "PY314",
152
+ "PY315",
153
+ "PYARROW_INSTALLED",
154
+ "PYARROW_MIN_VERSION",
155
+ "PYPY",
156
+ "WASM",
157
+ "is_numpy_dev",
158
+ "pa_version_under17p0",
159
+ "pa_version_under18p0",
160
+ "pa_version_under19p0",
161
+ "pa_version_under20p0",
162
+ "pa_version_under21p0",
163
+ "pa_version_under22p0",
164
+ "pa_version_under23p0",
165
+ "pa_version_under25p0",
166
+ "pa_version_under26p0",
167
+ ]
venv/lib/python3.14/site-packages/pandas/compat/_constants.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ _constants
3
+ ======
4
+
5
+ Constants relevant for the Python implementation.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import platform
11
+ import sys
12
+ import sysconfig
13
+
14
+ IS64 = sys.maxsize > 2**32
15
+
16
+ PY312 = sys.version_info >= (3, 12)
17
+ PY313 = sys.version_info >= (3, 13)
18
+ PY314 = sys.version_info >= (3, 14)
19
+ PY315 = sys.version_info >= (3, 15)
20
+ PYPY = platform.python_implementation() == "PyPy"
21
+ WASM = (sys.platform == "emscripten") or (platform.machine() in ["wasm32", "wasm64"])
22
+ ISMUSL = "musl" in (sysconfig.get_config_var("HOST_GNU_TYPE") or "")
23
+ # the refcount for self in a chained __setitem__/.(i)loc indexing/method call
24
+ REF_COUNT = 2 if PY314 else 3
25
+ REF_COUNT_IDX = 2
26
+ REF_COUNT_METHOD = 1 if PY314 else 2
27
+ CHAINED_WARNING_DISABLED = PYPY
28
+
29
+
30
+ __all__ = [
31
+ "IS64",
32
+ "ISMUSL",
33
+ "PY312",
34
+ "PY313",
35
+ "PY314",
36
+ "PY315",
37
+ "PYPY",
38
+ "WASM",
39
+ ]
venv/lib/python3.14/site-packages/pandas/compat/_cpu.py ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Detection of the CPU allocation actually available to this process.
3
+
4
+ Used to bound the default worker count for parallel I/O, so that a default
5
+ :func:`~pandas.read_csv` does not oversubscribe a machine on which the process
6
+ has been given only a slice of the CPUs -- a CPU affinity mask, or a cgroup CPU
7
+ quota as set by ``docker --cpus`` and Kubernetes CPU limits.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import functools
13
+ import os
14
+
15
+
16
+ def _read_sysfs_int(path: str) -> int | None:
17
+ try:
18
+ with open(path, encoding="utf-8") as fh:
19
+ return int(fh.read().strip())
20
+ except (OSError, ValueError):
21
+ return None
22
+
23
+
24
+ def _read_sysfs_str(path: str) -> str | None:
25
+ # ValueError as well as OSError, matching _read_sysfs_int: a non-UTF-8 byte
26
+ # raises UnicodeDecodeError, and this feeds available_cpu_count(), which
27
+ # _default_n_workers calls unguarded -- so it would surface out of read_csv
28
+ # rather than falling back.
29
+ try:
30
+ with open(path, encoding="utf-8") as fh:
31
+ return fh.read().strip()
32
+ except (OSError, ValueError):
33
+ return None
34
+
35
+
36
+ def _parse_cgroup_v2_quota(text: str) -> float | None:
37
+ """
38
+ CPU count from a cgroup v2 ``cpu.max`` value.
39
+
40
+ The format is ``"<quota> <period>"`` (both in microseconds) or ``"max"`` when
41
+ the CPU time is unlimited; returns ``None`` when unlimited or malformed.
42
+ """
43
+ parts = text.split()
44
+ if not parts or parts[0] == "max":
45
+ return None
46
+ try:
47
+ quota = int(parts[0])
48
+ period = int(parts[1]) if len(parts) > 1 else 100000
49
+ except ValueError:
50
+ return None
51
+ if quota > 0 and period > 0:
52
+ return quota / period
53
+ return None
54
+
55
+
56
+ def _cgroup_cpu_quota() -> float | None:
57
+ """CPUs allowed by the process's cgroup CFS quota, or None if unlimited."""
58
+ # cgroup v2; under a cgroup namespace (the common container case) this is the
59
+ # limit the container itself sees.
60
+ text = _read_sysfs_str("/sys/fs/cgroup/cpu.max")
61
+ if text is not None:
62
+ return _parse_cgroup_v2_quota(text)
63
+ # cgroup v1
64
+ quota = _read_sysfs_int("/sys/fs/cgroup/cpu/cpu.cfs_quota_us")
65
+ period = _read_sysfs_int("/sys/fs/cgroup/cpu/cpu.cfs_period_us")
66
+ if quota and quota > 0 and period and period > 0:
67
+ return quota / period
68
+ return None
69
+
70
+
71
+ @functools.lru_cache(maxsize=1)
72
+ def available_cpu_count() -> int | None:
73
+ """
74
+ Number of CPUs the process may actually use, or None if unconstrained.
75
+
76
+ Takes the tighter of the CPU affinity mask (``taskset``, SLURM cpusets) and
77
+ the cgroup CFS quota (Docker ``--cpus``, Kubernetes CPU limits), so a default
78
+ worker count does not oversubscribe a restricted environment. Returns
79
+ ``None`` only where neither limit is probed -- in practice macOS and
80
+ Windows. macOS exposes no affinity mask at all; Windows does (via
81
+ ``GetProcessAffinityMask`` and job-object rate limits) but it is not
82
+ implemented here, so a restricted Windows process falls back to the
83
+ logical CPU count clamped by ``_MAX_DEFAULT_WORKERS``.
84
+ On Linux ``sched_getaffinity`` always succeeds, so an unconstrained box
85
+ reports its full logical CPU count rather than ``None``.
86
+
87
+ Cached for the process lifetime: the CPU allocation is static in practice
88
+ (affinity is normally set once at startup, and a live quota change via
89
+ ``docker update`` or an in-place pod resize is rare), and this is on the
90
+ ``read_csv`` hot path.
91
+ """
92
+ limits = []
93
+ if hasattr(os, "sched_getaffinity"):
94
+ try:
95
+ limits.append(len(os.sched_getaffinity(0)))
96
+ except OSError:
97
+ pass
98
+ quota = _cgroup_cpu_quota()
99
+ if quota is not None:
100
+ limits.append(max(1, int(quota)))
101
+ return min(limits) if limits else None
venv/lib/python3.14/site-packages/pandas/compat/_optional.py ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import importlib
4
+ import sys
5
+ from typing import (
6
+ TYPE_CHECKING,
7
+ Literal,
8
+ overload,
9
+ )
10
+ import warnings
11
+
12
+ from pandas.util._exceptions import find_stack_level
13
+
14
+ from pandas.util.version import Version
15
+
16
+ if TYPE_CHECKING:
17
+ import types
18
+
19
+ # Update install.rst, pixi.toml,
20
+ # deps_minimum.toml & pyproject.toml when updating versions!
21
+
22
+ VERSIONS = {
23
+ "adbc-driver-postgresql": "1.7.0",
24
+ "adbc-driver-sqlite": "1.7.0",
25
+ "bs4": "4.13.4",
26
+ "bottleneck": "1.5.0",
27
+ "fastparquet": "2024.11.0",
28
+ "fsspec": "2025.7.0",
29
+ "html5lib": "1.1",
30
+ "gcsfs": "2025.7.0",
31
+ "jinja2": "3.1.6",
32
+ "lxml.etree": "6.0.0",
33
+ "matplotlib": "3.10.5",
34
+ "numba": "0.61.2",
35
+ "numexpr": "2.11.0",
36
+ "odfpy": "1.4.1",
37
+ "openpyxl": "3.1.5",
38
+ "psycopg2": "2.9.10", # (dt dec pq3 ext lo64)
39
+ "pymysql": "1.1.1",
40
+ "pyarrow": "16.0.0",
41
+ "pyiceberg": "0.9.1",
42
+ "pyreadstat": "1.3.0",
43
+ "pytest": "8.3.4",
44
+ "python-calamine": "0.4.0",
45
+ "pytz": "2020.1", # keep this pinned (https://github.com/pandas-dev/pandas/pull/65133)
46
+ "pyxlsb": "1.0.10",
47
+ "s3fs": "2025.7.0",
48
+ "scipy": "1.16.1",
49
+ "sqlalchemy": "2.0.42",
50
+ "tables": "3.10.2",
51
+ "tabulate": "0.9.0",
52
+ "xarray": "2025.7.1",
53
+ "xlrd": "2.0.2",
54
+ "xlsxwriter": "3.2.5",
55
+ "zstandard": "0.23.0",
56
+ "qtpy": "2.4.3",
57
+ "pyqt5": "5.15.11",
58
+ }
59
+
60
+ # A mapping from import name to package name (on PyPI) for packages where
61
+ # these two names are different.
62
+
63
+ INSTALL_MAPPING = {
64
+ "bs4": "beautifulsoup4",
65
+ "bottleneck": "Bottleneck",
66
+ "jinja2": "Jinja2",
67
+ "lxml.etree": "lxml",
68
+ "odf": "odfpy",
69
+ "python_calamine": "python-calamine",
70
+ "sqlalchemy": "SQLAlchemy",
71
+ "tables": "pytables",
72
+ }
73
+
74
+
75
+ def get_version(module: types.ModuleType) -> str:
76
+ version = getattr(module, "__version__", None)
77
+
78
+ if version is None:
79
+ raise ImportError(f"Can't determine version for {module.__name__}")
80
+ if module.__name__ == "psycopg2":
81
+ # psycopg2 appends " (dt dec pq3 ext lo64)" to its version
82
+ version = version.split()[0]
83
+ return version
84
+
85
+
86
+ @overload
87
+ def import_optional_dependency(
88
+ name: str,
89
+ extra: str = ...,
90
+ min_version: str | None = ...,
91
+ *,
92
+ errors: Literal["raise"] = ...,
93
+ ) -> types.ModuleType: ...
94
+
95
+
96
+ @overload
97
+ def import_optional_dependency(
98
+ name: str,
99
+ extra: str = ...,
100
+ min_version: str | None = ...,
101
+ *,
102
+ errors: Literal["warn", "ignore"],
103
+ ) -> types.ModuleType | None: ...
104
+
105
+
106
+ def import_optional_dependency(
107
+ name: str,
108
+ extra: str = "",
109
+ min_version: str | None = None,
110
+ *,
111
+ errors: Literal["raise", "warn", "ignore"] = "raise",
112
+ ) -> types.ModuleType | None:
113
+ """
114
+ Import an optional dependency.
115
+
116
+ By default, if a dependency is missing an ImportError with a nice
117
+ message will be raised. If a dependency is present, but too old,
118
+ we raise.
119
+
120
+ Parameters
121
+ ----------
122
+ name : str
123
+ The module name.
124
+ extra : str
125
+ Additional text to include in the ImportError message.
126
+ errors : str {'raise', 'warn', 'ignore'}
127
+ What to do when a dependency is not found or its version is too old.
128
+
129
+ * raise : Raise an ImportError
130
+ * warn : Only applicable when a module's version is to old.
131
+ Warns that the version is too old and returns None
132
+ * ignore: If the module is not installed, return None, otherwise,
133
+ return the module, even if the version is too old.
134
+ It's expected that users validate the version locally when
135
+ using ``errors="ignore"`` (see. ``io/html.py``)
136
+ min_version : str, default None
137
+ Specify a minimum version that is different from the global pandas
138
+ minimum version required.
139
+ Returns
140
+ -------
141
+ maybe_module : Optional[ModuleType]
142
+ The imported module, when found and the version is correct.
143
+ None is returned when the package is not found and `errors`
144
+ is False, or when the package's version is too old and `errors`
145
+ is ``'warn'`` or ``'ignore'``.
146
+ """
147
+ assert errors in {"warn", "raise", "ignore"}
148
+
149
+ package_name = INSTALL_MAPPING.get(name)
150
+ install_name = package_name if package_name is not None else name
151
+
152
+ msg = (
153
+ f"`Import {install_name}` failed. {extra} "
154
+ f"Use pip, conda, or your preferred package management tool "
155
+ f"to install the {install_name} package."
156
+ )
157
+ try:
158
+ module = importlib.import_module(name)
159
+ except ImportError as err:
160
+ if errors == "raise":
161
+ raise ImportError(msg) from err
162
+ return None
163
+
164
+ # Handle submodules: if we have submodule, grab parent module from sys.modules
165
+ parent = name.split(".", maxsplit=1)[0]
166
+ if parent != name:
167
+ install_name = parent
168
+ module_to_get = sys.modules[install_name]
169
+ else:
170
+ module_to_get = module
171
+ minimum_version = min_version if min_version is not None else VERSIONS.get(parent)
172
+ if minimum_version:
173
+ version = get_version(module_to_get)
174
+ if version and Version(version) < Version(minimum_version):
175
+ msg = (
176
+ f"Pandas requires version '{minimum_version}' or newer of '{parent}' "
177
+ f"(version '{version}' currently installed)."
178
+ )
179
+ if errors == "warn":
180
+ warnings.warn(
181
+ msg,
182
+ UserWarning,
183
+ stacklevel=find_stack_level(),
184
+ )
185
+ return None
186
+ elif errors == "raise":
187
+ raise ImportError(msg)
188
+ else:
189
+ return None
190
+
191
+ return module