-
-
Notifications
You must be signed in to change notification settings - Fork 141
GroupBy agg rejects a dict argument #361
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
Comments
I think the fix here is to do the following in AggFuncTypeDictSeries: TypeAlias = dict[Hashable, AggFuncTypeBase]
AggFuncTypeDictFrame: TypeAlias = dict[
Hashable, Union[AggFuncTypeBase, list[AggFuncTypeBase]]
] Change |
That didn't seem to do it - it actually appears to be my third bullet point above - |
In general, the issue with using |
I don't think an untyped The part that I think is actually worth exploring more is enumerating all of the string literals from here: https://github.com/pandas-dev/pandas/blob/main/pandas/core/groupby/base.py @Dr-Irv - Re |
That would be a good idea to restrict the strings.
OK, thanks for checking. |
I'll start with the code snippet and the errors:
So there are a several different things happening here:
List[str]
todf.columns
. Not really related to the issue in the title, but might as well fix this at the same time.agg_dict
, I would expect the type to beDict[Hashable, str]
, since in a lot of places we are treating the column data type asHashable
. This may be dependent on the broader issue of anIndex
needing to be a generic type.agg_dict
toDict[Hashable, str]
this still is not accepted byagg()
. There may be a covariance thing at play here, it may need to beMapping
instead ofDict
, but I haven't investigated this too closely yet.There's enough things going on here that I didn't want to just start changing things around in the annotations before I could pinpoint exactly what we should be changing.
The text was updated successfully, but these errors were encountered: