diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 9aba9723e0546..f9761f82880b7 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -2408,7 +2408,10 @@ def _reindex_output(self, output): if groupings is None: return output elif len(groupings) == 1: - return output + if self.sort: + return output.sort_index() + else: + return output # if we only care about the observed values # we are done