Skip to content

Commit 0bde3f9

Browse files
committed
Simple stub of group_any
1 parent 7527e1c commit 0bde3f9

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

pandas/_libs/groupby_helper.pxi.in

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,3 +791,27 @@ def group_cummax_{{name}}(ndarray[{{dest_type2}}, ndim=2] out,
791791
out[i, j] = mval
792792

793793
{{endfor}}
794+
795+
@cython.boundscheck(False)
796+
@cython.wraparound(False)
797+
def group_any(ndarray[uint8_t, ndim=2] out,
798+
ndarray[int64_t] counts,
799+
ndarray[:, :] values,
800+
ndarray[int64_t] labels,
801+
bint skipna):
802+
cdef:
803+
Py_ssize_t i, N
804+
ndarray[uint8_t] mask
805+
806+
N, _ = (<object> labels).shape
807+
808+
out = np.zeros_like(out)
809+
mask = values[:, 0].astype(np.bool)
810+
811+
for i in range(N):
812+
lab = labels[i]
813+
if lab < 0:
814+
continue
815+
816+
if mask[lab]:
817+
out[lab, 0] = 1

0 commit comments

Comments
 (0)