55These are user facing as the result of the ``df.groupby(...)`` operations,
66which here returns a DataFrameGroupBy object.
77"""
8- from collections import OrderedDict , abc , defaultdict , namedtuple
8+ from collections import abc , defaultdict , namedtuple
99import copy
1010from functools import partial
1111from textwrap import dedent
1414 TYPE_CHECKING ,
1515 Any ,
1616 Callable ,
17+ Dict ,
1718 FrozenSet ,
1819 Iterable ,
1920 List ,
@@ -306,7 +307,7 @@ def _aggregate_multiple_funcs(self, arg):
306307
307308 arg = zip (columns , arg )
308309
309- results = OrderedDict ()
310+ results = {}
310311 for name , func in arg :
311312 obj = self
312313
@@ -443,7 +444,7 @@ def _get_index() -> Index:
443444 return self ._reindex_output (result )
444445
445446 def _aggregate_named (self , func , * args , ** kwargs ):
446- result = OrderedDict ()
447+ result = {}
447448
448449 for name , group in self :
449450 group .name = name
@@ -1122,7 +1123,7 @@ def _aggregate_frame(self, func, *args, **kwargs) -> DataFrame:
11221123 axis = self .axis
11231124 obj = self ._obj_with_exclusions
11241125
1125- result : OrderedDict = OrderedDict ()
1126+ result : Dict [ Union [ int , str ], Union [ NDFrame , np . ndarray ]] = {}
11261127 if axis != obj ._info_axis_number :
11271128 for name , data in self :
11281129 fres = func (data , * args , ** kwargs )
@@ -1139,7 +1140,7 @@ def _aggregate_item_by_item(self, func, *args, **kwargs) -> DataFrame:
11391140 # only for axis==0
11401141
11411142 obj = self ._obj_with_exclusions
1142- result : OrderedDict = OrderedDict ()
1143+ result : Dict [ Union [ int , str ], NDFrame ] = {}
11431144 cannot_agg = []
11441145 for item in obj :
11451146 data = obj [item ]
@@ -1877,7 +1878,7 @@ def _normalize_keyword_aggregation(kwargs):
18771878 Normalize user-provided "named aggregation" kwargs.
18781879
18791880 Transforms from the new ``Mapping[str, NamedAgg]`` style kwargs
1880- to the old OrderedDict [str, List[scalar]]].
1881+ to the old Dict [str, List[scalar]]].
18811882
18821883 Parameters
18831884 ----------
@@ -1895,11 +1896,11 @@ def _normalize_keyword_aggregation(kwargs):
18951896 Examples
18961897 --------
18971898 >>> _normalize_keyword_aggregation({'output': ('input', 'sum')})
1898- (OrderedDict([( 'input', ['sum'])]) , ('output',), [('input', 'sum')])
1899+ ({ 'input': ['sum']} , ('output',), [('input', 'sum')])
18991900 """
19001901 # Normalize the aggregation functions as Mapping[column, List[func]],
19011902 # process normally, then fixup the names.
1902- # TODO: aggspec type: typing.OrderedDict [str, List[AggScalar]]
1903+ # TODO: aggspec type: typing.Dict [str, List[AggScalar]]
19031904 # May be hitting https://github.com/python/mypy/issues/5958
19041905 # saying it doesn't have an attribute __name__
19051906 aggspec = defaultdict (list )
0 commit comments