File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
crates/polars-core/src/series/implementations
py-polars/tests/unit/operations Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,11 @@ impl private::PrivateSeries for SeriesWrap<StringChunked> {
6969 self . 0 . agg_max ( groups)
7070 }
7171
72+ #[ cfg( feature = "algorithm_group_by" ) ]
73+ unsafe fn agg_sum ( & self , _groups : & GroupsType ) -> Series {
74+ invalid_operation_panic ! ( agg_sum, self )
75+ }
76+
7277 fn subtract ( & self , rhs : & Series ) -> PolarsResult < Series > {
7378 NumOpsDispatch :: subtract ( & self . 0 , rhs)
7479 }
Original file line number Diff line number Diff line change 1212import polars as pl
1313import polars .selectors as cs
1414from polars import Expr
15- from polars .exceptions import ColumnNotFoundError
15+ from polars .exceptions import (
16+ ColumnNotFoundError ,
17+ InvalidOperationError ,
18+ )
1619from polars .meta import get_index_type
1720from polars .testing import assert_frame_equal , assert_series_equal
1821from polars .testing .parametric import column , dataframes , series
@@ -2724,3 +2727,10 @@ def test_agg_first_last_non_null_25405() -> None:
27242727 }
27252728 )
27262729 assert_frame_equal (result .collect (), expected )
2730+
2731+
2732+ def test_group_by_sum_on_strings_should_error_24659 () -> None :
2733+ with pytest .raises (
2734+ InvalidOperationError , match = r"sum.*operation not supported for dtype.*str"
2735+ ):
2736+ pl .DataFrame ({"str" : ["a" , "b" ]}).group_by (1 ).agg (pl .col .str .sum ())
You can’t perform that action at this time.
0 commit comments