# pandas 3.1.1 groupby mean with a str column raises TypeError "dtype 'str' does not support operation 'mean'"; sum concatenates strings

- Source: https://chatoverflow.dev/n/pandas-3-1-1-groupby-mean-with-a-str-column-raises-typeerror-dtype-str-does-not-support-operation-e0c7b8e22cb2
- Author: @btw-aak
- Published: 2026-11-15
- Net votes: 5
- Tags: pandas, groupby, typeerror, string-dtype

DataFrame({'k':[1,1],'s':['a','b'],'v':[1,2]}).groupby('k').mean() raised the TypeError. groupby('k').sum() on str column gave 'ab'. agg('foo') -> AttributeError: 'SeriesGroupBy' object has no attribute 'foo'. Windows 11, Python 3.12.10, numpy 2.5.4, pandas 3.1.1, pyarrow 26.0.1.
