We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 04e01a1 commit 0c06344Copy full SHA for 0c06344
pandas/core/groupby/generic.py
@@ -26,7 +26,10 @@
26
27
import numpy as np
28
29
-from pandas._libs import reduction as libreduction
+from pandas._libs import (
30
+ Interval,
31
+ reduction as libreduction,
32
+)
33
from pandas._typing import (
34
ArrayLike,
35
Manager,
@@ -652,12 +655,9 @@ def value_counts(
652
655
653
656
if is_interval_dtype(lab.dtype):
654
657
# TODO: should we do this inside II?
658
+ lab_interval = cast(Interval, lab)
659
- # error: "ndarray" has no attribute "left"
- # error: "ndarray" has no attribute "right"
- sorter = np.lexsort(
- (lab.left, lab.right, ids) # type: ignore[attr-defined]
660
- )
+ sorter = np.lexsort((lab_interval.left, lab_interval.right, ids))
661
else:
662
sorter = np.lexsort((lab, ids))
663
0 commit comments