-
- Notifications
You must be signed in to change notification settings - Fork 19.4k
BUG: Exception when frame constructed from dict of iterators #26356
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
BUG: Exception when frame constructed from dict of iterators #26356
Conversation
pandas/core/common.py Outdated
| return obj | ||
| | ||
| | ||
| def maybe_itarable_to_list(obj: Any) -> Any: |
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.
this routine already exists, look around in this file
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.
I did look and have looked again now. It is not there. There's a _iterable_not_string but that's different.
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.
shouldn't the signature be Union[Iterable, Any] -> Union[List, Any]
?
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.
I think they're equivalent,as Union[Iterable, Any] is the same as Any? E.g. if the returned value from maybe_itarable_to_list is called x, if could cause an error to call x.append, if x was e.g. an int.
Both version pass the mypi checks.
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.
right but the 2nd is much more informative to a reader
Codecov Report
@@ Coverage Diff @@ ## master #26356 +/- ## ========================================== - Coverage 92.04% 92.03% -0.01% ========================================== Files 175 175 Lines 52289 52293 +4 ========================================== Hits 48130 48130 - Misses 4159 4163 +4
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@ ## master #26356 +/- ## ========================================== - Coverage 91.74% 91.73% -0.01% ========================================== Files 174 174 Lines 50748 50752 +4 ========================================== Hits 46557 46557 - Misses 4191 4195 +4
Continue to review full report at Codecov.
|
28c2b86 to ee6d6be Compare ee6d6be to 8b986d6 Compare | Trying something, not the final PR. |
52a1ff8 to 5717015 Compare ee63d3e to ce6128a Compare | I figured out the problem. |
| Is this ok? |
pandas/core/common.py Outdated
| return obj | ||
| | ||
| | ||
| def maybe_itarable_to_list(obj: Any) -> Any: |
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.
shouldn't the signature be Union[Iterable, Any] -> Union[List, Any]
?
664f489 to c63f418 Compare | lgtm. if you can update the annotation, ping on green. |
c63f418 to 29834d7 Compare | thanks @topper-123 keep em coming! |
git diff upstream/master -u -- "*.py" | flake8 --diffAllows iterators as values when instantiating DataFrames using dicts.
Also collected the iterable-to-list functionality from core/series.py into core/common.py, so it is shared.