Skip to content

Commit b3e5432

Browse files
authored
Merge pull request #170 from pandas-dev/master
Sync Fork from Upstream Repo
2 parents 6f05b90 + 2196004 commit b3e5432

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1161
-198
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,3 +206,8 @@ repos:
206206
files: ^pandas/core/
207207
exclude: ^pandas/core/api\.py$
208208
types: [python]
209+
- id: no-bool-in-core-generic
210+
name: Use bool_t instead of bool in pandas/core/generic.py
211+
entry: python scripts/no_bool_in_generic.py
212+
language: python
213+
files: ^pandas/core/generic\.py$

LICENSES/PYUPGRADE_LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2017 Anthony Sottile
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

pandas/_libs/algos.pyi

Lines changed: 293 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,293 @@
1+
# Note: this covers algos.pyx and algos_common_helper but NOT algos_take_helper
2+
from typing import Any
3+
4+
import numpy as np
5+
6+
class Infinity:
7+
"""
8+
Provide a positive Infinity comparison method for ranking.
9+
"""
10+
def __eq__(self, other) -> bool: ...
11+
def __ne__(self, other) -> bool: ...
12+
def __lt__(self, other) -> bool: ...
13+
def __le__(self, other) -> bool: ...
14+
def __gt__(self, other) -> bool: ...
15+
def __ge__(self, other) -> bool: ...
16+
17+
18+
class NegInfinity:
19+
"""
20+
Provide a negative Infinity comparison method for ranking.
21+
"""
22+
def __eq__(self, other) -> bool: ...
23+
def __ne__(self, other) -> bool: ...
24+
def __lt__(self, other) -> bool: ...
25+
def __le__(self, other) -> bool: ...
26+
def __gt__(self, other) -> bool: ...
27+
def __ge__(self, other) -> bool: ...
28+
29+
30+
def unique_deltas(
31+
arr: np.ndarray, # const int64_t[:]
32+
) -> np.ndarray: ... # np.ndarray[np.int64, ndim=1]
33+
34+
35+
def is_lexsorted(list_of_arrays: list[np.ndarray]) -> bool: ...
36+
37+
38+
def groupsort_indexer(
39+
index: np.ndarray, # const int64_t[:]
40+
ngroups: int,
41+
) -> tuple[
42+
np.ndarray, # ndarray[int64_t, ndim=1]
43+
np.ndarray, # ndarray[int64_t, ndim=1]
44+
]:
45+
...
46+
47+
48+
def kth_smallest(
49+
a: np.ndarray, # numeric[:]
50+
k: int,
51+
) -> Any: ... # numeric
52+
53+
54+
# ----------------------------------------------------------------------
55+
# Pairwise correlation/covariance
56+
57+
58+
59+
def nancorr(
60+
mat: np.ndarray, # const float64_t[:, :]
61+
cov: bool = False,
62+
minp=None,
63+
) -> np.ndarray: # np.ndarray[float64_t, ndim=2]
64+
...
65+
66+
67+
def nancorr_spearman(
68+
mat: np.ndarray, # ndarray[float64_t, ndim=2]
69+
minp: int = 1,
70+
) -> np.ndarray: # np.ndarray[np.float64, ndim=2]
71+
...
72+
73+
74+
def nancorr_kendall(
75+
mat: np.ndarray, # ndarray[float64_t, ndim=2]
76+
minp: int = 1,
77+
) -> np.ndarray: # np.ndarray[float64, ndim=2]
78+
...
79+
80+
# ----------------------------------------------------------------------
81+
82+
# ctypedef fused algos_t:
83+
# float64_t
84+
# float32_t
85+
# object
86+
# int64_t
87+
# int32_t
88+
# int16_t
89+
# int8_t
90+
# uint64_t
91+
# uint32_t
92+
# uint16_t
93+
# uint8_t
94+
95+
96+
def validate_limit(nobs: int | None, limit=None) -> int: ...
97+
98+
99+
def pad(
100+
old: np.ndarray, # ndarray[algos_t]
101+
new: np.ndarray, # ndarray[algos_t]
102+
limit=None,
103+
) -> np.ndarray: ... # np.ndarray[np.intp, ndim=1]
104+
105+
106+
def pad_inplace(
107+
values: np.ndarray, # algos_t[:]
108+
mask: np.ndarray, # uint8_t[:]
109+
limit=None,
110+
) -> None: ...
111+
112+
113+
def pad_2d_inplace(
114+
values: np.ndarray, # algos_t[:, :]
115+
mask: np.ndarray, # const uint8_t[:, :]
116+
limit=None,
117+
) -> None:
118+
...
119+
120+
121+
def backfill(
122+
old: np.ndarray, # ndarray[algos_t]
123+
new: np.ndarray, # ndarray[algos_t]
124+
limit=None,
125+
) -> np.ndarray: # np.ndarray[np.intp, ndim=1]
126+
...
127+
128+
def backfill_inplace(
129+
values: np.ndarray, # algos_t[:]
130+
mask: np.ndarray, # uint8_t[:]
131+
limit=None,
132+
) -> None: ...
133+
134+
135+
def backfill_2d_inplace(
136+
values: np.ndarray, # algos_t[:, :]
137+
mask: np.ndarray, # const uint8_t[:, :]
138+
limit=None,
139+
) -> None: ...
140+
141+
142+
def is_monotonic(
143+
arr: np.ndarray, # ndarray[algos_t, ndim=1]
144+
timelike: bool
145+
) -> tuple[bool, bool, bool]:
146+
...
147+
148+
# ----------------------------------------------------------------------
149+
# rank_1d, rank_2d
150+
# ----------------------------------------------------------------------
151+
152+
# ctypedef fused rank_t:
153+
# object
154+
# float64_t
155+
# uint64_t
156+
# int64_t
157+
158+
159+
def rank_1d(
160+
values: np.ndarray, # ndarray[rank_t, ndim=1]
161+
labels: np.ndarray, # const int64_t[:]
162+
is_datetimelike: bool = ...,
163+
ties_method=...,
164+
ascending: bool = ...,
165+
pct: bool = ...,
166+
na_option=...,
167+
) -> np.ndarray: ... # np.ndarray[float64_t, ndim=1]
168+
169+
170+
def rank_2d(
171+
in_arr: np.ndarray, # ndarray[rank_t, ndim=2]
172+
axis: int = ...,
173+
is_datetimelike: bool = ...,
174+
ties_method=...,
175+
ascending: bool = ...,
176+
na_option=...,
177+
pct: bool = ...,
178+
) -> np.ndarray: ... # np.ndarray[float64_t, ndim=1]
179+
180+
181+
def diff_2d(
182+
arr: np.ndarray, # ndarray[diff_t, ndim=2]
183+
out: np.ndarray, # ndarray[out_t, ndim=2]
184+
periods: int,
185+
axis: int,
186+
datetimelike: bool = ...,
187+
) -> None: ...
188+
189+
190+
def ensure_platform_int(arr: object) -> np.ndarray: ...
191+
192+
def ensure_object(arr: object) -> np.ndarray: ...
193+
194+
def ensure_float64(arr: object, copy=True) -> np.ndarray: ...
195+
196+
def ensure_float32(arr: object, copy=True) -> np.ndarray: ...
197+
198+
def ensure_int8(arr: object, copy=True) -> np.ndarray: ...
199+
200+
def ensure_int16(arr: object, copy=True) -> np.ndarray: ...
201+
202+
def ensure_int32(arr: object, copy=True) -> np.ndarray: ...
203+
204+
def ensure_int64(arr: object, copy=True) -> np.ndarray: ...
205+
206+
def ensure_uint8(arr: object, copy=True) -> np.ndarray: ...
207+
208+
def ensure_uint16(arr: object, copy=True) -> np.ndarray: ...
209+
210+
def ensure_uint32(arr: object, copy=True) -> np.ndarray: ...
211+
212+
def ensure_uint64(arr: object, copy=True) -> np.ndarray: ...
213+
214+
215+
def take_1d_int8_int8(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
216+
def take_1d_int8_int32(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
217+
def take_1d_int8_int64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
218+
def take_1d_int8_float64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
219+
def take_1d_int16_int16(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
220+
def take_1d_int16_int32(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
221+
def take_1d_int16_int64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
222+
def take_1d_int16_float64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
223+
def take_1d_int32_int32(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
224+
def take_1d_int32_int64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
225+
def take_1d_int32_float64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
226+
def take_1d_int64_int64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
227+
def take_1d_int64_float64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
228+
def take_1d_float32_float32(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
229+
def take_1d_float32_float64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
230+
def take_1d_float64_float64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
231+
def take_1d_object_object(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
232+
def take_1d_bool_bool(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
233+
def take_1d_bool_object(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
234+
235+
def take_2d_axis0_int8_int8(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
236+
def take_2d_axis0_int8_int32(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
237+
def take_2d_axis0_int8_int64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
238+
def take_2d_axis0_int8_float64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
239+
def take_2d_axis0_int16_int16(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
240+
def take_2d_axis0_int16_int32(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
241+
def take_2d_axis0_int16_int64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
242+
def take_2d_axis0_int16_float64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
243+
def take_2d_axis0_int32_int32(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
244+
def take_2d_axis0_int32_int64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
245+
def take_2d_axis0_int32_float64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
246+
def take_2d_axis0_int64_int64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
247+
def take_2d_axis0_int64_float64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
248+
def take_2d_axis0_float32_float32(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
249+
def take_2d_axis0_float32_float64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
250+
def take_2d_axis0_float64_float64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
251+
def take_2d_axis0_object_object(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
252+
def take_2d_axis0_bool_bool(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
253+
def take_2d_axis0_bool_object(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
254+
255+
def take_2d_axis1_int8_int8(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
256+
def take_2d_axis1_int8_int32(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
257+
def take_2d_axis1_int8_int64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
258+
def take_2d_axis1_int8_float64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
259+
def take_2d_axis1_int16_int16(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
260+
def take_2d_axis1_int16_int32(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
261+
def take_2d_axis1_int16_int64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
262+
def take_2d_axis1_int16_float64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
263+
def take_2d_axis1_int32_int32(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
264+
def take_2d_axis1_int32_int64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
265+
def take_2d_axis1_int32_float64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
266+
def take_2d_axis1_int64_int64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
267+
def take_2d_axis1_int64_float64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
268+
def take_2d_axis1_float32_float32(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
269+
def take_2d_axis1_float32_float64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
270+
def take_2d_axis1_float64_float64(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
271+
def take_2d_axis1_object_object(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
272+
def take_2d_axis1_bool_bool(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
273+
def take_2d_axis1_bool_object(values: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=...) -> None: ...
274+
275+
def take_2d_multi_int8_int8(values: np.ndarray, indexer, out: np.ndarray, fill_value=...) -> None: ...
276+
def take_2d_multi_int8_int32(values: np.ndarray, indexer, out: np.ndarray, fill_value=...) -> None: ...
277+
def take_2d_multi_int8_int64(values: np.ndarray, indexer, out: np.ndarray, fill_value=...) -> None: ...
278+
def take_2d_multi_int8_float64(values: np.ndarray, indexer, out: np.ndarray, fill_value=...) -> None: ...
279+
def take_2d_multi_int16_int16(values: np.ndarray, indexer, out: np.ndarray, fill_value=...) -> None: ...
280+
def take_2d_multi_int16_int32(values: np.ndarray, indexer, out: np.ndarray, fill_value=...) -> None: ...
281+
def take_2d_multi_int16_int64(values: np.ndarray, indexer, out: np.ndarray, fill_value=...) -> None: ...
282+
def take_2d_multi_int16_float64(values: np.ndarray, indexer, out: np.ndarray, fill_value=...) -> None: ...
283+
def take_2d_multi_int32_int32(values: np.ndarray, indexer, out: np.ndarray, fill_value=...) -> None: ...
284+
def take_2d_multi_int32_int64(values: np.ndarray, indexer, out: np.ndarray, fill_value=...) -> None: ...
285+
def take_2d_multi_int32_float64(values: np.ndarray, indexer, out: np.ndarray, fill_value=...) -> None: ...
286+
def take_2d_multi_int64_float64(values: np.ndarray, indexer, out: np.ndarray, fill_value=...) -> None: ...
287+
def take_2d_multi_float32_float32(values: np.ndarray, indexer, out: np.ndarray, fill_value=...) -> None: ...
288+
def take_2d_multi_float32_float64(values: np.ndarray, indexer, out: np.ndarray, fill_value=...) -> None: ...
289+
def take_2d_multi_float64_float64(values: np.ndarray, indexer, out: np.ndarray, fill_value=...) -> None: ...
290+
def take_2d_multi_object_object(values: np.ndarray, indexer, out: np.ndarray, fill_value=...) -> None: ...
291+
def take_2d_multi_bool_bool(values: np.ndarray, indexer, out: np.ndarray, fill_value=...) -> None: ...
292+
def take_2d_multi_bool_object(values: np.ndarray, indexer, out: np.ndarray, fill_value=...) -> None: ...
293+
def take_2d_multi_int64_int64(values: np.ndarray, indexer, out: np.ndarray, fill_value=...) -> None: ...

pandas/_libs/algos.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ ctypedef fused algos_t:
563563
uint8_t
564564

565565

566-
def validate_limit(nobs: int, limit=None) -> int:
566+
def validate_limit(nobs: int | None, limit=None) -> int:
567567
"""
568568
Check that the `limit` argument is a positive integer.
569569

pandas/_libs/internals.pyi

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ from typing import (
66

77
import numpy as np
88

9-
from pandas._typing import ArrayLike
9+
from pandas._typing import (
10+
ArrayLike,
11+
T,
12+
)
1013

1114
def slice_len(slc: slice, objlen: int = ...) -> int: ...
1215

@@ -50,9 +53,16 @@ class BlockPlacement:
5053
def append(self, others: list[BlockPlacement]) -> BlockPlacement: ...
5154

5255

53-
class Block:
56+
class SharedBlock:
5457
_mgr_locs: BlockPlacement
5558
ndim: int
5659
values: ArrayLike
5760

5861
def __init__(self, values: ArrayLike, placement: BlockPlacement, ndim: int): ...
62+
63+
class NumpyBlock(SharedBlock):
64+
values: np.ndarray
65+
def getitem_block_index(self: T, slicer: slice) -> T: ...
66+
67+
class Block(SharedBlock):
68+
...

0 commit comments

Comments
 (0)