Skip to content

Commit cdb3f57

Browse files
committed
Cleaned up call signature
1 parent f545476 commit cdb3f57

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

pandas/_libs/groupby_helper.pxi.in

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,12 +795,18 @@ def group_cummax_{{name}}(ndarray[{{dest_type2}}, ndim=2] out,
795795
@cython.boundscheck(False)
796796
@cython.wraparound(False)
797797
def group_any(ndarray[int64_t] out,
798-
ndarray[int64_t] mask,
798+
ndarray values,
799799
ndarray[int64_t] labels,
800800
bint skipna):
801801
cdef:
802802
Py_ssize_t i, N=len(labels)
803803
int64_t lab
804+
ndarray[int64_t] mask
805+
806+
if values.dtype is np.object:
807+
mask = np.array(bool(x) for x in values).astype(np.int64)
808+
else:
809+
mask = values.astype(np.bool).astype(np.int64)
804810

805811
with nogil:
806812
for i in range(N):

pandas/core/groupby.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,18 +1223,12 @@ class GroupBy(_GroupBy):
12231223
@Appender(_doc_template)
12241224
def any(self, skipna=True):
12251225
"""Returns True if any value in the group is truthful, else False"""
1226-
obj = self._obj_with_exclusions
1227-
12281226
labels, _, _ = self.grouper.group_info
1229-
12301227
output = collections.OrderedDict()
1228+
12311229
for name, obj in self._iterate_slices():
12321230
result = np.zeros(self.ngroups, dtype=np.int64)
1233-
if obj.dtype is np.object:
1234-
mask = np.array(bool(x) for x in obj.values)
1235-
else:
1236-
mask = obj.values.astype(np.bool)
1237-
libgroupby.group_any(result, mask.astype(np.int64), labels, skipna)
1231+
libgroupby.group_any(result, obj.values, labels, skipna)
12381232
output[name] = result.astype(np.bool)
12391233

12401234
return self._wrap_aggregated_output(output)

0 commit comments

Comments
 (0)