-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: OrderedDict -> Dict #30497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLN: OrderedDict -> Dict #30497
Changes from 12 commits
02e079c
90331b4
86a5bea
b0ecd34
a99a00f
4f5c0f1
e1df836
2f4ce3e
c0169e4
d3614a2
9955781
7f4b7ba
dfdb654
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
These are user facing as the result of the ``df.groupby(...)`` operations, | ||
which here returns a DataFrameGroupBy object. | ||
""" | ||
from collections import OrderedDict, abc, defaultdict, namedtuple | ||
from collections import abc, defaultdict, namedtuple | ||
import copy | ||
from functools import partial | ||
from textwrap import dedent | ||
|
@@ -306,7 +306,7 @@ def _aggregate_multiple_funcs(self, arg): | |
|
||
arg = zip(columns, arg) | ||
|
||
results = OrderedDict() | ||
results = {} | ||
for name, func in arg: | ||
obj = self | ||
|
||
|
@@ -443,7 +443,7 @@ def _get_index() -> Index: | |
return self._reindex_output(result) | ||
|
||
def _aggregate_named(self, func, *args, **kwargs): | ||
result = OrderedDict() | ||
result = {} | ||
|
||
for name, group in self: | ||
group.name = name | ||
|
@@ -1119,7 +1119,7 @@ def _aggregate_frame(self, func, *args, **kwargs) -> DataFrame: | |
axis = self.axis | ||
obj = self._obj_with_exclusions | ||
|
||
result: OrderedDict = OrderedDict() | ||
result: dict = {} | ||
if axis != obj._info_axis_number: | ||
for name, data in self: | ||
fres = func(data, *args, **kwargs) | ||
|
@@ -1136,7 +1136,7 @@ def _aggregate_item_by_item(self, func, *args, **kwargs) -> DataFrame: | |
# only for axis==0 | ||
|
||
obj = self._obj_with_exclusions | ||
result: OrderedDict = OrderedDict() | ||
result: dict = {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment |
||
cannot_agg = [] | ||
for item in obj: | ||
data = obj[item] | ||
|
@@ -1874,7 +1874,7 @@ def _normalize_keyword_aggregation(kwargs): | |
Normalize user-provided "named aggregation" kwargs. | ||
|
||
Transforms from the new ``Mapping[str, NamedAgg]`` style kwargs | ||
to the old OrderedDict[str, List[scalar]]]. | ||
to the old Dict[str, List[scalar]]]. | ||
|
||
Parameters | ||
---------- | ||
|
@@ -1892,11 +1892,11 @@ def _normalize_keyword_aggregation(kwargs): | |
Examples | ||
-------- | ||
>>> _normalize_keyword_aggregation({'output': ('input', 'sum')}) | ||
(OrderedDict([('input', ['sum'])]), ('output',), [('input', 'sum')]) | ||
({'input': ['sum']}, ('output',), [('input', 'sum')]) | ||
""" | ||
# Normalize the aggregation functions as Mapping[column, List[func]], | ||
# process normally, then fixup the names. | ||
# TODO: aggspec type: typing.OrderedDict[str, List[AggScalar]] | ||
# TODO: aggspec type: typing.Dict[str, List[AggScalar]] | ||
# May be hitting https://github.com/python/mypy/issues/5958 | ||
# saying it doesn't have an attribute __name__ | ||
aggspec = defaultdict(list) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
Module for formatting output data in HTML. | ||
""" | ||
|
||
from collections import OrderedDict | ||
from textwrap import dedent | ||
from typing import IO, Any, Dict, Iterable, List, Mapping, Optional, Tuple, Union, cast | ||
|
||
|
@@ -138,10 +137,10 @@ def _write_cell( | |
else: | ||
start_tag = "<{kind}>".format(kind=kind) | ||
|
||
esc: Union[OrderedDict[str, str], Dict] | ||
esc: Union[Dict[str, str], Dict] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Arguably orthogonal but this is somewhat of a strange annotation - is it not always just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line can be removed now as it is no longer required to silence There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure - removed |
||
if self.escape: | ||
# escape & first to prevent double escaping of & | ||
esc = OrderedDict([("&", r"&"), ("<", r"<"), (">", r">")]) | ||
esc = {"&": r"&", "<": r"<", ">": r">"} | ||
else: | ||
esc = {} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use the builtins for annotations, rather want to import
Dict
from typing. Would be extra useful if you can figure out the subtypes that need to be addedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure - I ran the tests cases that touch this logic and think I've now got the right subtypes