@@ -14,6 +14,7 @@ import numpy as np
14
14
from pandas ._typing import (
15
15
ArrayLike ,
16
16
DtypeObj ,
17
+ npt ,
17
18
)
18
19
19
20
# placeholder until we can specify np.ndarray[object, ndim=2]
@@ -63,7 +64,7 @@ def map_infer(
63
64
) -> np .ndarray : ...
64
65
@overload # both convert_datetime and convert_to_nullable_integer False -> np.ndarray
65
66
def maybe_convert_objects (
66
- objects : np . ndarray , # np.ndarray[object]
67
+ objects : npt . NDArray [ np .object_ ],
67
68
* ,
68
69
try_float : bool = ...,
69
70
safe : bool = ...,
@@ -76,7 +77,7 @@ def maybe_convert_objects(
76
77
) -> np .ndarray : ...
77
78
@overload
78
79
def maybe_convert_objects (
79
- objects : np . ndarray , # np.ndarray[object]
80
+ objects : npt . NDArray [ np .object_ ],
80
81
* ,
81
82
try_float : bool = ...,
82
83
safe : bool = ...,
@@ -89,7 +90,7 @@ def maybe_convert_objects(
89
90
) -> ArrayLike : ...
90
91
@overload
91
92
def maybe_convert_objects (
92
- objects : np . ndarray , # np.ndarray[object]
93
+ objects : npt . NDArray [ np .object_ ],
93
94
* ,
94
95
try_float : bool = ...,
95
96
safe : bool = ...,
@@ -102,7 +103,7 @@ def maybe_convert_objects(
102
103
) -> ArrayLike : ...
103
104
@overload
104
105
def maybe_convert_objects (
105
- objects : np . ndarray , # np.ndarray[object]
106
+ objects : npt . NDArray [ np .object_ ],
106
107
* ,
107
108
try_float : bool = ...,
108
109
safe : bool = ...,
@@ -115,7 +116,7 @@ def maybe_convert_objects(
115
116
) -> ArrayLike : ...
116
117
@overload
117
118
def maybe_convert_objects (
118
- objects : np . ndarray , # np.ndarray[object]
119
+ objects : npt . NDArray [ np .object_ ],
119
120
* ,
120
121
try_float : bool = ...,
121
122
safe : bool = ...,
@@ -128,15 +129,15 @@ def maybe_convert_objects(
128
129
) -> ArrayLike : ...
129
130
@overload
130
131
def maybe_convert_numeric (
131
- values : np . ndarray , # np.ndarray[object]
132
+ values : npt . NDArray [ np .object_ ],
132
133
na_values : set ,
133
134
convert_empty : bool = True ,
134
135
coerce_numeric : bool = False ,
135
136
convert_to_masked_nullable : Literal [False ] = ...,
136
137
) -> tuple [np .ndarray , None ]: ...
137
138
@overload
138
139
def maybe_convert_numeric (
139
- values : np . ndarray , # np.ndarray[object]
140
+ values : npt . NDArray [ np .object_ ],
140
141
na_values : set ,
141
142
convert_empty : bool = True ,
142
143
coerce_numeric : bool = False ,
@@ -151,32 +152,32 @@ def ensure_string_array(
151
152
convert_na_value : bool = True ,
152
153
copy : bool = True ,
153
154
skipna : bool = True ,
154
- ) -> np .ndarray : ... # np.ndarray[object]
155
+ ) -> npt . NDArray [ np .object_ ] : ...
155
156
def infer_datetimelike_array (
156
- arr : np . ndarray , # np.ndarray[object]
157
+ arr : npt . NDArray [ np .object_ ],
157
158
) -> tuple [str , bool ]: ...
158
159
def astype_intsafe (
159
- arr : np . ndarray , # np.ndarray[object]
160
+ arr : npt . NDArray [ np .object_ ],
160
161
new_dtype : np .dtype ,
161
162
) -> np .ndarray : ...
162
- def fast_zip (ndarrays : list ) -> np .ndarray : ... # np.ndarray[object]
163
+ def fast_zip (ndarrays : list ) -> npt . NDArray [ np .object_ ] : ...
163
164
164
165
# TODO: can we be more specific about rows?
165
166
def to_object_array_tuples (rows : object ) -> ndarray_obj_2d : ...
166
167
def tuples_to_object_array (
167
- tuples : np . ndarray , # np.ndarray[object]
168
+ tuples : npt . NDArray [ np .object_ ],
168
169
) -> ndarray_obj_2d : ...
169
170
170
171
# TODO: can we be more specific about rows?
171
172
def to_object_array (rows : object , min_width : int = 0 ) -> ndarray_obj_2d : ...
172
173
def dicts_to_array (dicts : list , columns : list ) -> ndarray_obj_2d : ...
173
174
def maybe_booleans_to_slice (
174
- mask : np . ndarray , # ndarray[uint8_t]
175
- ) -> slice | np .ndarray : ... # np.ndarray[np.uint8]
175
+ mask : npt . NDArray [ np . uint8 ],
176
+ ) -> slice | npt . NDArray [ np .uint8 ] : ...
176
177
def maybe_indices_to_slice (
177
- indices : np . ndarray , # np.ndarray [np.intp]
178
+ indices : npt . NDArray [np .intp ],
178
179
max_len : int ,
179
- ) -> slice | np .ndarray : ... # np.ndarray[np.uint8]
180
+ ) -> slice | npt . NDArray [ np .intp ] : ...
180
181
def is_all_arraylike (obj : list ) -> bool : ...
181
182
182
183
# -----------------------------------------------------------------
@@ -192,14 +193,14 @@ def map_infer_mask(
192
193
dtype : np .dtype = ...,
193
194
) -> np .ndarray : ...
194
195
def indices_fast (
195
- index : np . ndarray , # ndarray[intp_t]
196
+ index : npt . NDArray [ np . intp ],
196
197
labels : np .ndarray , # const int64_t[:]
197
198
keys : list ,
198
- sorted_labels : list [np . ndarray ], # list[ndarray[ np.int64]]
199
+ sorted_labels : list [npt . NDArray [ np .int64 ]],
199
200
) -> dict : ...
200
201
def generate_slices (
201
202
labels : np .ndarray , ngroups : int # const intp_t[:]
202
- ) -> tuple [np . ndarray , np .ndarray ,]: ... # np.ndarray [np.int64] # np.ndarray[np.int64]
203
+ ) -> tuple [npt . NDArray [ np .int64 ], npt . NDArray [np .int64 ]]: ...
203
204
def count_level_2d (
204
205
mask : np .ndarray , # ndarray[uint8_t, ndim=2, cast=True],
205
206
labels : np .ndarray , # const intp_t[:]
@@ -211,7 +212,7 @@ def get_level_sorter(
211
212
starts : np .ndarray , # const intp_t[:]
212
213
) -> np .ndarray : ... # np.ndarray[np.intp, ndim=1]
213
214
def generate_bins_dt64 (
214
- values : np . ndarray , # np.ndarray [np.int64]
215
+ values : npt . NDArray [np .int64 ],
215
216
binner : np .ndarray , # const int64_t[:]
216
217
closed : object = "left" ,
217
218
hasnans : bool = False ,
@@ -224,5 +225,5 @@ def has_infs(arr: np.ndarray) -> bool: ... # const floating[:]
224
225
def get_reverse_indexer (
225
226
indexer : np .ndarray , # const intp_t[:]
226
227
length : int ,
227
- ) -> np .ndarray : ... # np.ndarray[np.intp]
228
+ ) -> npt . NDArray [ np .intp ] : ...
228
229
def is_bool_list (obj : list ) -> bool : ...
0 commit comments