4
4
import numpy as np
5
5
import pytest
6
6
7
- from pandas ._libs import groupby
7
+ from pandas ._libs . groupby import group_cumprod_float64 , group_cumsum
8
8
9
9
from pandas .core .dtypes .common import ensure_platform_int , is_timedelta64_dtype
10
10
@@ -545,14 +545,14 @@ def _check_cython_group_transform_cumulative(pd_op, np_op, dtype):
545
545
def test_cython_group_transform_cumsum (any_real_dtype ):
546
546
# see gh-4095
547
547
dtype = np .dtype (any_real_dtype ).type
548
- pd_op , np_op = groupby . group_cumsum , np .cumsum
548
+ pd_op , np_op = group_cumsum , np .cumsum
549
549
_check_cython_group_transform_cumulative (pd_op , np_op , dtype )
550
550
551
551
552
552
def test_cython_group_transform_cumprod ():
553
553
# see gh-4095
554
554
dtype = np .float64
555
- pd_op , np_op = groupby . group_cumprod_float64 , np .cumproduct
555
+ pd_op , np_op = group_cumprod_float64 , np .cumproduct
556
556
_check_cython_group_transform_cumulative (pd_op , np_op , dtype )
557
557
558
558
@@ -567,21 +567,21 @@ def test_cython_group_transform_algos():
567
567
data = np .array ([[1 ], [2 ], [3 ], [np .nan ], [4 ]], dtype = "float64" )
568
568
actual = np .zeros_like (data )
569
569
actual .fill (np .nan )
570
- groupby . group_cumprod_float64 (actual , data , labels , ngroups , is_datetimelike )
570
+ group_cumprod_float64 (actual , data , labels , ngroups , is_datetimelike )
571
571
expected = np .array ([1 , 2 , 6 , np .nan , 24 ], dtype = "float64" )
572
572
tm .assert_numpy_array_equal (actual [:, 0 ], expected )
573
573
574
574
actual = np .zeros_like (data )
575
575
actual .fill (np .nan )
576
- groupby . group_cumsum (actual , data , labels , ngroups , is_datetimelike )
576
+ group_cumsum (actual , data , labels , ngroups , is_datetimelike )
577
577
expected = np .array ([1 , 3 , 6 , np .nan , 10 ], dtype = "float64" )
578
578
tm .assert_numpy_array_equal (actual [:, 0 ], expected )
579
579
580
580
# timedelta
581
581
is_datetimelike = True
582
582
data = np .array ([np .timedelta64 (1 , "ns" )] * 5 , dtype = "m8[ns]" )[:, None ]
583
583
actual = np .zeros_like (data , dtype = "int64" )
584
- groupby . group_cumsum (actual , data .view ("int64" ), labels , ngroups , is_datetimelike )
584
+ group_cumsum (actual , data .view ("int64" ), labels , ngroups , is_datetimelike )
585
585
expected = np .array (
586
586
[
587
587
np .timedelta64 (1 , "ns" ),
0 commit comments