1
- # Copyright (c) 2024, NVIDIA CORPORATION.
1
+ # Copyright (c) 2024-2025 , NVIDIA CORPORATION.
2
2
3
3
from cython.operator cimport dereference
4
4
from libcpp.cast cimport dynamic_cast
@@ -20,9 +20,16 @@ from pylibcudf.libcudf.aggregation cimport (
20
20
make_count_aggregation,
21
21
make_covariance_aggregation,
22
22
make_ewma_aggregation,
23
+ make_histogram_aggregation,
24
+ make_m2_aggregation,
23
25
make_max_aggregation,
24
26
make_mean_aggregation,
25
27
make_median_aggregation,
28
+ make_merge_m2_aggregation,
29
+ make_merge_histogram_aggregation,
30
+ make_merge_lists_aggregation,
31
+ make_merge_sets_aggregation,
32
+ make_merge_tdigest_aggregation,
26
33
make_min_aggregation,
27
34
make_nth_element_aggregation,
28
35
make_nunique_aggregation,
@@ -32,6 +39,7 @@ from pylibcudf.libcudf.aggregation cimport (
32
39
make_std_aggregation,
33
40
make_sum_aggregation,
34
41
make_sum_of_squares_aggregation,
42
+ make_tdigest_aggregation,
35
43
make_udf_aggregation,
36
44
make_variance_aggregation,
37
45
rank_method,
@@ -82,9 +90,16 @@ __all__ = [
82
90
" count" ,
83
91
" covariance" ,
84
92
" ewma" ,
93
+ " histogram" ,
94
+ " m2" ,
85
95
" max" ,
86
96
" mean" ,
87
97
" median" ,
98
+ " merge_histogram" ,
99
+ " merge_lists" ,
100
+ " merge_m2" ,
101
+ " merge_sets" ,
102
+ " merge_tdigest" ,
88
103
" min" ,
89
104
" nth_element" ,
90
105
" nunique" ,
@@ -94,6 +109,7 @@ __all__ = [
94
109
" std" ,
95
110
" sum" ,
96
111
" sum_of_squares" ,
112
+ " tdigest" ,
97
113
" udf" ,
98
114
" variance" ,
99
115
]
@@ -639,3 +655,150 @@ cpdef Aggregation rank(
639
655
)
640
656
)
641
657
)
658
+
659
+
660
+ cpdef Aggregation histogram():
661
+ """ Create a histogram aggregation.
662
+
663
+ For details, see :cpp:func:`make_histogram_aggregation`.
664
+
665
+ Returns
666
+ -------
667
+ Aggregation
668
+ The histogram aggregation.
669
+ """
670
+ return Aggregation.from_libcudf(
671
+ move(make_histogram_aggregation[aggregation]())
672
+ )
673
+
674
+
675
+ cpdef Aggregation m2():
676
+ """ Create a M2 aggregation.
677
+
678
+ For details, see :cpp:func:`make_m2_aggregation`.
679
+
680
+ Returns
681
+ -------
682
+ Aggregation
683
+ The M2 aggregation.
684
+ """
685
+ return Aggregation.from_libcudf(
686
+ move(make_m2_aggregation[aggregation]())
687
+ )
688
+
689
+
690
+ cpdef Aggregation merge_m2():
691
+ """ Create a merge M2 aggregation.
692
+
693
+ For details, see :cpp:func:`make_merge_m2_aggregation`.
694
+
695
+ Returns
696
+ -------
697
+ Aggregation
698
+ The merge M2 aggregation.
699
+ """
700
+ return Aggregation.from_libcudf(
701
+ move(make_merge_m2_aggregation[aggregation]())
702
+ )
703
+
704
+
705
+ cpdef Aggregation merge_histogram():
706
+ """ Create a merge histogram aggregation.
707
+
708
+ For details, see :cpp:func:`make_merge_histogram_aggregation`.
709
+
710
+ Returns
711
+ -------
712
+ Aggregation
713
+ The merge histogram aggregation.
714
+ """
715
+ return Aggregation.from_libcudf(
716
+ move(make_merge_histogram_aggregation[aggregation]())
717
+ )
718
+
719
+
720
+ cpdef Aggregation merge_lists():
721
+ """ Create a merge lists aggregation.
722
+
723
+ For details, see :cpp:func:`make_merge_lists_aggregation`.
724
+
725
+ Returns
726
+ -------
727
+ Aggregation
728
+ The merge lists aggregation.
729
+ """
730
+ return Aggregation.from_libcudf(
731
+ move(make_merge_lists_aggregation[aggregation]())
732
+ )
733
+
734
+
735
+ cpdef Aggregation merge_sets(
736
+ null_equality nulls_equal = null_equality.EQUAL,
737
+ nan_equality nans_equal = nan_equality.ALL_EQUAL,
738
+ ):
739
+ """ Create a merge sets aggregation.
740
+
741
+ For details, see :cpp:func:`make_merge_sets_aggregation`.
742
+
743
+ Parameters
744
+ ----------
745
+ nulls_equal : null_equality, default EQUAL
746
+ Whether or not nulls should be considered equal.
747
+ nans_equal : nan_equality, default ALL_EQUAL
748
+ Whether or not NaNs should be considered equal.
749
+
750
+ Returns
751
+ -------
752
+ Aggregation
753
+ The merge sets aggregation.
754
+ """
755
+ return Aggregation.from_libcudf(
756
+ move(
757
+ make_merge_sets_aggregation[aggregation](
758
+ nulls_equal,
759
+ nans_equal,
760
+ )
761
+ )
762
+ )
763
+
764
+
765
+ cpdef Aggregation merge_tdigest(int max_centroids):
766
+ """ Create a merge TDIGEST aggregation.
767
+
768
+ For details, see :cpp:func:`make_merge_tdigest_aggregation`.
769
+
770
+ Parameters
771
+ ----------
772
+ max_centroids : int
773
+ Parameter controlling compression level and accuracy
774
+ on subsequent queries on the output tdigest data.
775
+
776
+ Returns
777
+ -------
778
+ Aggregation
779
+ The merge TDIGEST aggregation.
780
+ """
781
+ return Aggregation.from_libcudf(
782
+ move(make_merge_tdigest_aggregation[aggregation](max_centroids))
783
+ )
784
+
785
+
786
+ cpdef Aggregation tdigest(int max_centroids):
787
+ """ Create a TDIGEST aggregation.
788
+
789
+ For details, see :cpp:func:`make_tdigest_aggregation`.
790
+
791
+ Parameters
792
+ ----------
793
+ max_centroids : int
794
+ Parameter controlling compression level and accuracy
795
+ on subsequent queries on the output tdigest data.
796
+
797
+ Returns
798
+ -------
799
+ Aggregation
800
+ The TDIGEST aggregation.
801
+ """
802
+ return Aggregation.from_libcudf(
803
+ move(make_tdigest_aggregation[aggregation](max_centroids))
804
+ )
0 commit comments