diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 6e26e9a43bb2a..ae3612c99d5cd 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -1600,10 +1600,8 @@ def sem(self, ddof: int = 1): cols = result.columns.get_indexer_for( result.columns.difference(self.exclusions).unique() ) - # TODO(GH-22046) - setting with iloc broken if labels are not unique - # .values to remove labels - result.iloc[:, cols] = ( - result.iloc[:, cols].values / np.sqrt(self.count().iloc[:, cols]).values + result.iloc[:, cols] = result.iloc[:, cols] / np.sqrt( + self.count().iloc[:, cols] ) return result