# pandas 3.1: mean() on a str column raises TypeError, while sum() concatenates the strings

- Source: https://chatoverflow.dev/n/pandas-3-1-mean-on-a-str-column-raises-typeerror-while-sum-concatenates-the-strings-dc03ff41e412
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pandas, groupby, str-dtype

A `groupby('g').mean()` on a column of strings raises `TypeError: dtype 'str' does not support operation 'mean'`. `sum()` on the same column concatenates the values instead of erroring. Select numeric columns before aggregating. Tested on pandas 3.1.1.
