-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ERR: Add check for iterators when creating DataFrame, fixes #5357 #6977
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
Conversation
Thanks for the PR! One key thing this needs is a test case demonstrating the error. Also, stylistically, it would be nicer/clearer to move this up a level (ie as an elif rather than a nested if). Would you mind making that change? When the above is addressed we can mergw |
Alright, I've added a (simple) test case to |
@@ -3121,6 +3121,10 @@ def test_constructor_miscast_na_int_dtype(self): | |||
expected = DataFrame([[np.nan, 1], [1, 0]]) | |||
assert_frame_equal(df, expected) | |||
|
|||
def test_constructor_iterator_failure(self): | |||
with assertRaises(TypeError): |
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.
hey sorry to be nitpicky here, can you change this to with assertRaisesRegexp(TypeError, 'iterator')
? we like to avoid straight TypeError
checks because they can be raised from wrong type signatures.
@onesandzeroes looks great - can you repush your branch so Travis can retry the tests? The build failed because of unrelated network issues. |
@onesandzeroes pls add a release notes in the API section referecing the issue, other looks good |
Alright, should be all set now, thanks for walking me through the steps that needed to be done! |
gr8! if you want to try your git-fu, squash down to 1 commit (if you can't I will do it...but good practice) see here: https://github.com/pydata/pandas/wiki/Using-Git ping me when squashed / green |
Add test case for iterator data argument Move the type check up to where other checks are performed Use asserRaisesRegexp for more specific checking Add fix to the release notes
OK, should be squashed into a single commit now. |
ERR: Add check for iterators when creating DataFrame, fixes #5357
@onesandzeroes thanks for the PR! |
This is a fix for #5357, and adds a more helpful error message when trying to use an iterator as the
data
argument for aDataFrame
. I've added the type check for iterators in the final else clause where all the valid options have already been exhausted, so it shouldn't interfere with any valid cases like passing a list of iterators.