-
-
Notifications
You must be signed in to change notification settings - Fork 133
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
Should from_dict be annotated to allow sequence data values? #929
Comments
I would say no as not even a list/array-like is document to be accepted. Depending on pandas-dev/pandas#58814 we should widen the type to Mapping. |
The summary says "Construct DataFrame from dict of array-like or dicts.", so I think we should allow a sequence here. |
This is related to #928 . Not clear if the docs are wrong on |
The
And the codepath for
So I suspect it's just a matter of the documentation being out of date. |
Yes, but we are talking about |
Ah, I see what you mean - people should be using from_records instead. I think I agree. |
Or just use the regular |
Created a pandas issue, see pandas-dev/pandas#58862. |
Describe the bug
It's not explicitly documented, but
Dataframe.from_dict
allows for a Sequence of values to be passed in fordata
.Is this something we want to annotate? It's fairly easy to demonstrate the failure case, but I'm not sure if this would be 'wider' than we'd want to allow for.
To Reproduce
Example code demonstrating the issue with mypy version 1.10.0, pandas 2.2.2
I receive the following errors:
error: No overload variant of "from_dict" of "DataFrame" matches argument type "tuple[dict[str, int], dict[str, int]]" [call-overload]
and
error: No overload variant of "from_dict" of "DataFrame" matches argument type "list[dict[str, int]]" [call-overload]
The code however, runs as you'd expect:
Additional context
Happy to raise the PR to address this, just wanted to check what the intended behaviour is first before doing the work.
The text was updated successfully, but these errors were encountered: