5
5
These are user facing as the result of the ``df.groupby(...)`` operations,
6
6
which here returns a DataFrameGroupBy object.
7
7
"""
8
- from collections import OrderedDict , abc , defaultdict , namedtuple
8
+ from collections import abc , defaultdict , namedtuple
9
9
import copy
10
10
from functools import partial
11
11
from textwrap import dedent
14
14
TYPE_CHECKING ,
15
15
Any ,
16
16
Callable ,
17
+ Dict ,
17
18
FrozenSet ,
18
19
Iterable ,
19
20
List ,
@@ -306,7 +307,7 @@ def _aggregate_multiple_funcs(self, arg):
306
307
307
308
arg = zip (columns , arg )
308
309
309
- results = OrderedDict ()
310
+ results = {}
310
311
for name , func in arg :
311
312
obj = self
312
313
@@ -443,7 +444,7 @@ def _get_index() -> Index:
443
444
return self ._reindex_output (result )
444
445
445
446
def _aggregate_named (self , func , * args , ** kwargs ):
446
- result = OrderedDict ()
447
+ result = {}
447
448
448
449
for name , group in self :
449
450
group .name = name
@@ -1122,7 +1123,7 @@ def _aggregate_frame(self, func, *args, **kwargs) -> DataFrame:
1122
1123
axis = self .axis
1123
1124
obj = self ._obj_with_exclusions
1124
1125
1125
- result : OrderedDict = OrderedDict ()
1126
+ result : Dict [ Union [ int , str ], Union [ NDFrame , np . ndarray ]] = {}
1126
1127
if axis != obj ._info_axis_number :
1127
1128
for name , data in self :
1128
1129
fres = func (data , * args , ** kwargs )
@@ -1139,7 +1140,7 @@ def _aggregate_item_by_item(self, func, *args, **kwargs) -> DataFrame:
1139
1140
# only for axis==0
1140
1141
1141
1142
obj = self ._obj_with_exclusions
1142
- result : OrderedDict = OrderedDict ()
1143
+ result : Dict [ Union [ int , str ], NDFrame ] = {}
1143
1144
cannot_agg = []
1144
1145
for item in obj :
1145
1146
data = obj [item ]
@@ -1877,7 +1878,7 @@ def _normalize_keyword_aggregation(kwargs):
1877
1878
Normalize user-provided "named aggregation" kwargs.
1878
1879
1879
1880
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]]].
1881
1882
1882
1883
Parameters
1883
1884
----------
@@ -1895,11 +1896,11 @@ def _normalize_keyword_aggregation(kwargs):
1895
1896
Examples
1896
1897
--------
1897
1898
>>> _normalize_keyword_aggregation({'output': ('input', 'sum')})
1898
- (OrderedDict([( 'input', ['sum'])]) , ('output',), [('input', 'sum')])
1899
+ ({ 'input': ['sum']} , ('output',), [('input', 'sum')])
1899
1900
"""
1900
1901
# Normalize the aggregation functions as Mapping[column, List[func]],
1901
1902
# process normally, then fixup the names.
1902
- # TODO: aggspec type: typing.OrderedDict [str, List[AggScalar]]
1903
+ # TODO: aggspec type: typing.Dict [str, List[AggScalar]]
1903
1904
# May be hitting https://github.com/python/mypy/issues/5958
1904
1905
# saying it doesn't have an attribute __name__
1905
1906
aggspec = defaultdict (list )
0 commit comments