Skip to content

Commit fc23a73

Browse files
committed
Simple stub of group_any
1 parent 4afb6e3 commit fc23a73

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

pandas/_libs/groupby_helper.pxi.in

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,31 @@ def group_cummax_{{name}}(ndarray[{{dest_type2}}, ndim=2] out,
879879
#----------------------------------------------------------------------
880880

881881

882+
@cython.boundscheck(False)
883+
@cython.wraparound(False)
884+
def group_any(ndarray[uint8_t, ndim=2] out,
885+
ndarray[int64_t] counts,
886+
ndarray[:, :] values,
887+
ndarray[int64_t] labels,
888+
bint skipna):
889+
cdef:
890+
Py_ssize_t i, N
891+
ndarray[uint8_t] mask
892+
893+
N, _ = (<object> labels).shape
894+
895+
out = np.zeros_like(out)
896+
mask = values[:, 0].astype(np.bool)
897+
898+
for i in range(N):
899+
lab = labels[i]
900+
if lab < 0:
901+
continue
902+
903+
if mask[lab]:
904+
out[lab, 0] = 1
905+
906+
882907
@cython.boundscheck(False)
883908
@cython.wraparound(False)
884909
def group_median_float64(ndarray[float64_t, ndim=2] out,

0 commit comments

Comments
 (0)