Skip to content

Commit 6a06a31

Browse files
committed
solved groupbyany bug
1 parent 4444e52 commit 6a06a31

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pandas/core/groupby/ops.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,13 @@ def _call_cython_op(
374374
if is_datetimelike:
375375
values = values.view("int64")
376376
is_numeric = True
377+
378+
# Fix for NaT handling: ensure NaT is treated as False in any() and all()
379+
if self.how in ["any", "all"]:
380+
# Set NaT (which is represented as the smallest int64) to False (0)
381+
nat_mask = values == np.iinfo(np.int64).min
382+
values[nat_mask] = 0 # Treat NaT as False
383+
377384
elif dtype.kind == "b":
378385
values = values.view("uint8")
379386
if values.dtype == "float16":

0 commit comments

Comments
 (0)