@@ -105,7 +105,7 @@ cdef inline float64_t median_linear(float64_t* a, int n) nogil:
105
105
def group_median_float64 (ndarray[float64_t , ndim = 2 ] out,
106
106
ndarray[int64_t] counts ,
107
107
ndarray[float64_t , ndim = 2 ] values,
108
- ndarray[int64_t ] labels ,
108
+ ndarray[intp_t ] labels ,
109
109
Py_ssize_t min_count = - 1 ):
110
110
"""
111
111
Only aggregates on axis=0
@@ -122,7 +122,7 @@ def group_median_float64(ndarray[float64_t, ndim=2] out,
122
122
ngroups = len (counts)
123
123
N, K = (< object > values).shape
124
124
125
- indexer, _counts = groupsort_indexer(ensure_platform_int( labels) , ngroups)
125
+ indexer, _counts = groupsort_indexer(labels, ngroups)
126
126
counts[:] = _counts[1 :]
127
127
128
128
data = np.empty((K, N), dtype = np.float64)
@@ -145,7 +145,7 @@ def group_median_float64(ndarray[float64_t, ndim=2] out,
145
145
@ cython.wraparound (False )
146
146
def group_cumprod_float64 (float64_t[:, ::1] out ,
147
147
const float64_t[:, :] values ,
148
- const int64_t [:] labels ,
148
+ const intp_t [:] labels ,
149
149
int ngroups ,
150
150
bint is_datetimelike ,
151
151
bint skipna = True ):
@@ -158,7 +158,7 @@ def group_cumprod_float64(float64_t[:, ::1] out,
158
158
Array to store cumprod in.
159
159
values : float64 array
160
160
Values to take cumprod of.
161
- labels : int64 array
161
+ labels : np.ndarray[np.intp]
162
162
Labels to group by.
163
163
ngroups : int
164
164
Number of groups, larger than all entries of `labels`.
@@ -175,7 +175,7 @@ def group_cumprod_float64(float64_t[:, ::1] out,
175
175
Py_ssize_t i, j, N, K, size
176
176
float64_t val
177
177
float64_t[:, ::1 ] accum
178
- int64_t lab
178
+ intp_t lab
179
179
180
180
N, K = (< object > values).shape
181
181
accum = np.ones((ngroups, K), dtype = np.float64)
@@ -202,7 +202,7 @@ def group_cumprod_float64(float64_t[:, ::1] out,
202
202
@ cython.wraparound (False )
203
203
def group_cumsum (numeric[:, ::1] out ,
204
204
ndarray[numeric , ndim = 2 ] values,
205
- const int64_t [:] labels ,
205
+ const intp_t [:] labels ,
206
206
int ngroups ,
207
207
is_datetimelike ,
208
208
bint skipna = True ):
@@ -215,7 +215,7 @@ def group_cumsum(numeric[:, ::1] out,
215
215
Array to store cumsum in.
216
216
values : array
217
217
Values to take cumsum of.
218
- labels : int64 array
218
+ labels : np.ndarray[np.intp]
219
219
Labels to group by.
220
220
ngroups : int
221
221
Number of groups, larger than all entries of `labels`.
@@ -232,7 +232,7 @@ def group_cumsum(numeric[:, ::1] out,
232
232
Py_ssize_t i, j, N, K, size
233
233
numeric val, y, t
234
234
numeric[:, ::1 ] accum, compensation
235
- int64_t lab
235
+ intp_t lab
236
236
237
237
N, K = (< object > values).shape
238
238
accum = np.zeros((ngroups, K), dtype = np.asarray(values).dtype)
@@ -269,12 +269,12 @@ def group_cumsum(numeric[:, ::1] out,
269
269
270
270
@ cython.boundscheck (False )
271
271
@ cython.wraparound (False )
272
- def group_shift_indexer (int64_t[::1] out , const int64_t [:] labels ,
272
+ def group_shift_indexer (int64_t[::1] out , const intp_t [:] labels ,
273
273
int ngroups , int periods ):
274
274
cdef:
275
- Py_ssize_t N, i, j, ii
275
+ Py_ssize_t N, i, j, ii, lab
276
276
int offset = 0 , sign
277
- int64_t lab, idxer, idxer_slot
277
+ int64_t idxer, idxer_slot
278
278
int64_t[::1 ] label_seen = np.zeros(ngroups, dtype = np.int64)
279
279
int64_t[:, ::1 ] label_indexer
280
280
@@ -321,7 +321,7 @@ def group_shift_indexer(int64_t[::1] out, const int64_t[:] labels,
321
321
322
322
@ cython.wraparound (False )
323
323
@ cython.boundscheck (False )
324
- def group_fillna_indexer (ndarray[int64_t] out , ndarray[int64_t ] labels ,
324
+ def group_fillna_indexer (ndarray[int64_t] out , ndarray[intp_t ] labels ,
325
325
ndarray[uint8_t] mask , object direction ,
326
326
int64_t limit , bint dropna ):
327
327
"""
@@ -331,8 +331,9 @@ def group_fillna_indexer(ndarray[int64_t] out, ndarray[int64_t] labels,
331
331
----------
332
332
out : array of int64_t values which this method will write its results to
333
333
Missing values will be written to with a value of -1
334
- labels : array containing unique label for each group, with its ordering
335
- matching up to the corresponding record in `values`
334
+ labels : np.ndarray[np.intp]
335
+ Array containing unique label for each group, with its ordering
336
+ matching up to the corresponding record in `values`.
336
337
mask : array of int64_t values where a 1 indicates a missing value
337
338
direction : {'ffill', 'bfill'}
338
339
Direction for fill to be applied (forwards or backwards, respectively)
@@ -344,17 +345,18 @@ def group_fillna_indexer(ndarray[int64_t] out, ndarray[int64_t] labels,
344
345
This method modifies the `out` parameter rather than returning an object
345
346
"""
346
347
cdef:
347
- Py_ssize_t i, N
348
- int64_t[:] sorted_labels
349
- int64_t idx, curr_fill_idx= - 1 , filled_vals= 0
348
+ Py_ssize_t i, N, idx
349
+ intp_t[:] sorted_labels
350
+ intp_t curr_fill_idx= - 1
351
+ int64_t filled_vals = 0
350
352
351
353
N = len (out)
352
354
353
355
# Make sure all arrays are the same size
354
356
assert N == len (labels) == len (mask)
355
357
356
358
sorted_labels = np.argsort(labels, kind = ' mergesort' ).astype(
357
- np.int64 , copy = False )
359
+ np.intp , copy = False )
358
360
if direction == ' bfill' :
359
361
sorted_labels = sorted_labels[::- 1 ]
360
362
@@ -385,7 +387,7 @@ def group_fillna_indexer(ndarray[int64_t] out, ndarray[int64_t] labels,
385
387
@ cython.wraparound (False )
386
388
def group_any_all (uint8_t[::1] out ,
387
389
const uint8_t[::1] values ,
388
- const int64_t [:] labels ,
390
+ const intp_t [:] labels ,
389
391
const uint8_t[::1] mask ,
390
392
object val_test ,
391
393
bint skipna ):
@@ -395,7 +397,8 @@ def group_any_all(uint8_t[::1] out,
395
397
Parameters
396
398
----------
397
399
out : array of values which this method will write its results to
398
- labels : array containing unique label for each group, with its
400
+ labels : np.ndarray[np.intp]
401
+ Array containing unique label for each group, with its
399
402
ordering matching up to the corresponding record in `values`
400
403
values : array containing the truth value of each element
401
404
mask : array indicating whether a value is na or not
@@ -411,7 +414,7 @@ def group_any_all(uint8_t[::1] out,
411
414
"""
412
415
cdef:
413
416
Py_ssize_t i, N = len (labels)
414
- int64_t lab
417
+ intp_t lab
415
418
uint8_t flag_val
416
419
417
420
if val_test == ' all' :
@@ -455,7 +458,7 @@ ctypedef fused complexfloating_t:
455
458
def _group_add (complexfloating_t[:, ::1] out ,
456
459
int64_t[::1] counts ,
457
460
ndarray[complexfloating_t , ndim = 2 ] values,
458
- const int64_t [:] labels ,
461
+ const intp_t [:] labels ,
459
462
Py_ssize_t min_count = 0 ):
460
463
"""
461
464
Only aggregates on axis=0 using Kahan summation
@@ -514,7 +517,7 @@ group_add_complex128 = _group_add['double complex']
514
517
def _group_prod (floating[:, ::1] out ,
515
518
int64_t[::1] counts ,
516
519
ndarray[floating , ndim = 2 ] values,
517
- const int64_t [:] labels ,
520
+ const intp_t [:] labels ,
518
521
Py_ssize_t min_count = 0 ):
519
522
"""
520
523
Only aggregates on axis=0
@@ -567,7 +570,7 @@ group_prod_float64 = _group_prod['double']
567
570
def _group_var (floating[:, ::1] out ,
568
571
int64_t[::1] counts ,
569
572
ndarray[floating , ndim = 2 ] values,
570
- const int64_t [:] labels ,
573
+ const intp_t [:] labels ,
571
574
Py_ssize_t min_count = - 1 ,
572
575
int64_t ddof = 1 ):
573
576
cdef:
@@ -625,7 +628,7 @@ group_var_float64 = _group_var['double']
625
628
def _group_mean (floating[:, ::1] out ,
626
629
int64_t[::1] counts ,
627
630
ndarray[floating , ndim = 2 ] values,
628
- const int64_t [::1] labels ,
631
+ const intp_t [::1] labels ,
629
632
Py_ssize_t min_count = - 1 ):
630
633
cdef:
631
634
Py_ssize_t i, j, N, K, lab, ncounts = len (counts)
@@ -681,7 +684,7 @@ group_mean_float64 = _group_mean['double']
681
684
def _group_ohlc (floating[:, ::1] out ,
682
685
int64_t[::1] counts ,
683
686
ndarray[floating , ndim = 2 ] values,
684
- const int64_t [:] labels ,
687
+ const intp_t [:] labels ,
685
688
Py_ssize_t min_count = - 1 ):
686
689
"""
687
690
Only aggregates on axis=0
@@ -732,7 +735,7 @@ group_ohlc_float64 = _group_ohlc['double']
732
735
@ cython.wraparound (False )
733
736
def group_quantile (ndarray[float64_t] out ,
734
737
ndarray[numeric , ndim = 1 ] values,
735
- ndarray[int64_t ] labels ,
738
+ ndarray[intp_t ] labels ,
736
739
ndarray[uint8_t] mask ,
737
740
float64_t q ,
738
741
object interpolation ):
@@ -743,7 +746,7 @@ def group_quantile(ndarray[float64_t] out,
743
746
----------
744
747
out : ndarray
745
748
Array of aggregated values that will be written to.
746
- labels : ndarray
749
+ labels : ndarray[np.intp]
747
750
Array containing the unique group labels.
748
751
values : ndarray
749
752
Array containing the values to apply the function against.
@@ -758,7 +761,7 @@ def group_quantile(ndarray[float64_t] out,
758
761
cdef:
759
762
Py_ssize_t i, N= len (labels), ngroups, grp_sz, non_na_sz
760
763
Py_ssize_t grp_start= 0 , idx= 0
761
- int64_t lab
764
+ intp_t lab
762
765
uint8_t interp
763
766
float64_t q_idx, frac, val, next_val
764
767
ndarray[int64_t] counts, non_na_counts, sort_arr
@@ -875,7 +878,7 @@ cdef inline bint _treat_as_na(rank_t val, bint is_datetimelike) nogil:
875
878
def group_last (rank_t[:, ::1] out ,
876
879
int64_t[::1] counts ,
877
880
ndarray[rank_t , ndim = 2 ] values,
878
- const int64_t [:] labels ,
881
+ const intp_t [:] labels ,
879
882
Py_ssize_t min_count = - 1 ):
880
883
"""
881
884
Only aggregates on axis=0
@@ -967,7 +970,7 @@ def group_last(rank_t[:, ::1] out,
967
970
def group_nth (rank_t[:, ::1] out ,
968
971
int64_t[::1] counts ,
969
972
ndarray[rank_t , ndim = 2 ] values,
970
- const int64_t [:] labels ,
973
+ const intp_t [:] labels ,
971
974
int64_t min_count = - 1 , int64_t rank = 1
972
975
):
973
976
"""
@@ -1059,7 +1062,7 @@ def group_nth(rank_t[:, ::1] out,
1059
1062
@ cython.wraparound (False )
1060
1063
def group_rank (float64_t[:, ::1] out ,
1061
1064
ndarray[rank_t , ndim = 2 ] values,
1062
- const int64_t [:] labels ,
1065
+ const intp_t [:] labels ,
1063
1066
int ngroups ,
1064
1067
bint is_datetimelike , object ties_method = " average" ,
1065
1068
bint ascending = True , bint pct = False , object na_option = " keep" ):
@@ -1070,7 +1073,8 @@ def group_rank(float64_t[:, ::1] out,
1070
1073
----------
1071
1074
out : array of float64_t values which this method will write its results to
1072
1075
values : array of rank_t values to be ranked
1073
- labels : array containing unique label for each group, with its ordering
1076
+ labels : np.ndarray[np.intp]
1077
+ Array containing unique label for each group, with its ordering
1074
1078
matching up to the corresponding record in `values`
1075
1079
ngroups : int
1076
1080
This parameter is not used, is needed to match signatures of other
@@ -1131,7 +1135,7 @@ ctypedef fused groupby_t:
1131
1135
cdef group_min_max(groupby_t[:, ::1 ] out,
1132
1136
int64_t[::1 ] counts,
1133
1137
ndarray[groupby_t, ndim= 2 ] values,
1134
- const int64_t [:] labels,
1138
+ const intp_t [:] labels,
1135
1139
Py_ssize_t min_count = - 1 ,
1136
1140
bint compute_max = True ):
1137
1141
"""
@@ -1145,7 +1149,7 @@ cdef group_min_max(groupby_t[:, ::1] out,
1145
1149
Input as a zeroed array, populated by group sizes during algorithm
1146
1150
values : array
1147
1151
Values to find column-wise min/max of.
1148
- labels : int64 array
1152
+ labels : np.ndarray[np.intp]
1149
1153
Labels to group by.
1150
1154
min_count : Py_ssize_t, default -1
1151
1155
The minimum number of non-NA group elements, NA result if threshold
@@ -1230,7 +1234,7 @@ cdef group_min_max(groupby_t[:, ::1] out,
1230
1234
def group_max (groupby_t[:, ::1] out ,
1231
1235
int64_t[::1] counts ,
1232
1236
ndarray[groupby_t , ndim = 2 ] values,
1233
- const int64_t [:] labels ,
1237
+ const intp_t [:] labels ,
1234
1238
Py_ssize_t min_count = - 1 ):
1235
1239
""" See group_min_max.__doc__"""
1236
1240
group_min_max(out, counts, values, labels, min_count = min_count, compute_max = True )
@@ -1241,7 +1245,7 @@ def group_max(groupby_t[:, ::1] out,
1241
1245
def group_min (groupby_t[:, ::1] out ,
1242
1246
int64_t[::1] counts ,
1243
1247
ndarray[groupby_t , ndim = 2 ] values,
1244
- const int64_t [:] labels ,
1248
+ const intp_t [:] labels ,
1245
1249
Py_ssize_t min_count = - 1 ):
1246
1250
""" See group_min_max.__doc__"""
1247
1251
group_min_max(out, counts, values, labels, min_count = min_count, compute_max = False )
@@ -1251,7 +1255,7 @@ def group_min(groupby_t[:, ::1] out,
1251
1255
@ cython.wraparound (False )
1252
1256
def group_cummin_max (groupby_t[:, ::1] out ,
1253
1257
ndarray[groupby_t , ndim = 2 ] values,
1254
- const int64_t [:] labels ,
1258
+ const intp_t [:] labels ,
1255
1259
int ngroups ,
1256
1260
bint is_datetimelike ,
1257
1261
bint compute_max ):
@@ -1264,7 +1268,7 @@ def group_cummin_max(groupby_t[:, ::1] out,
1264
1268
Array to store cummin/max in.
1265
1269
values : array
1266
1270
Values to take cummin/max of.
1267
- labels : int64 array
1271
+ labels : np.ndarray[np.intp]
1268
1272
Labels to group by.
1269
1273
ngroups : int
1270
1274
Number of groups, larger than all entries of `labels`.
@@ -1282,7 +1286,7 @@ def group_cummin_max(groupby_t[:, ::1] out,
1282
1286
Py_ssize_t i, j, N, K, size
1283
1287
groupby_t val, mval
1284
1288
ndarray[groupby_t, ndim= 2 ] accum
1285
- int64_t lab
1289
+ intp_t lab
1286
1290
1287
1291
N, K = (< object > values).shape
1288
1292
accum = np.empty((ngroups, K), dtype = np.asarray(values).dtype)
@@ -1319,7 +1323,7 @@ def group_cummin_max(groupby_t[:, ::1] out,
1319
1323
@ cython.wraparound (False )
1320
1324
def group_cummin (groupby_t[:, ::1] out ,
1321
1325
ndarray[groupby_t , ndim = 2 ] values,
1322
- const int64_t [:] labels ,
1326
+ const intp_t [:] labels ,
1323
1327
int ngroups ,
1324
1328
bint is_datetimelike ):
1325
1329
""" See group_cummin_max.__doc__"""
@@ -1330,7 +1334,7 @@ def group_cummin(groupby_t[:, ::1] out,
1330
1334
@ cython.wraparound (False )
1331
1335
def group_cummax (groupby_t[:, ::1] out ,
1332
1336
ndarray[groupby_t , ndim = 2 ] values,
1333
- const int64_t [:] labels ,
1337
+ const intp_t [:] labels ,
1334
1338
int ngroups ,
1335
1339
bint is_datetimelike ):
1336
1340
""" See group_cummin_max.__doc__"""
0 commit comments