Uh oh!
There was an error while loading. Please reload this page.
ARROW-7663: [Python] Raise better error message when passing mixed-type (int/string) Pandas dataframe to pyarrow Table - #8044
ARROW-7663: [Python] Raise better error message when passing mixed-type (int/string) Pandas dataframe to pyarrow Table#8044arw2019 wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
We lose the the more specific traceback and ZeroDivisionError message, in favor of
In [11]: classMyBrokenInt: ...: def__init__(self): ...: 1/0In [12]: pa.array([MyBrokenInt()], type=pa.int64()) ---------------------------------------------------------------------------ArrowInvalidTraceback (mostrecentcalllast)
<ipython-input-12-1cf156b165b3>in<module>---->1pa.array([MyBrokenInt()], type=pa.int64())
~/git_repo/arrow/python/pyarrow/array.pxiinpyarrow.lib.array()
269else:
270# ConvertPySequence does strict conversion if type is explicitly passed-->271return_sequence_to_array(obj, mask, size, type, pool, c_from_pandas)
272273~/git_repo/arrow/python/pyarrow/array.pxiinpyarrow.lib._sequence_to_array()
3839withnogil:
--->40check_status(ConvertPySequence(sequence, mask, options, &out))
4142ifout.get().num_chunks() ==1:
~/git_repo/arrow/python/pyarrow/error.pxiinpyarrow.lib.check_status()
8283ifstatus.IsInvalid():
--->84raiseArrowInvalid(message)
85elifstatus.IsIOError():
86# Note: OSError constructor isArrowInvalid: Couldnotconvert<__main__.MyBrokenIntobjectat0x7fc331394290>withtypeMyBrokenInt: triedtoconverttointbut this is the same message as what we get on master for
In [11]: classMyBrokenInt: ...: def__init__(self): ...: 1/1so maybe it's ok?
There was a problem hiding this comment.
I think that is fine, personally
9a73767 to
21166d3Compare
jorisvandenbossche
left a comment
There was a problem hiding this comment.
Thanks for working on this!
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
What did the error message say before, and what does it show now?
There was a problem hiding this comment.
On master it's
TypeError: anintegerisrequired (gottypepyarrow.lib.Int8Array)verus on this branch
ArrowInvalid: Couldnotconvert [
5
] withtypepyarrow.lib.Int8Array: triedtoconverttointThere was a problem hiding this comment.
Hmm, for this case I find the original error message clearer ..
That's the consequence of the scalar(..) conversion using the array conversion under the hood, I suppose?
But OK, I suppose this is fine (it's maybe mainly the multiline repr of the array in the middle of the sentence that makes it more confusing)
There was a problem hiding this comment.
I think that is fine, personally
There was a problem hiding this comment.
What are the cases that this couldn't be converted, but that objis an integer? When the integer is too big to fit in a C int?
There was a problem hiding this comment.
Yes, and also when converting a negative integer to a uint:
pa.scalar(-1, type='uint8')
No other tests are touched if I recompile without this check
716bd51 to
0735885Compareemkornfield
commented
Sep 14, 2020
@jorisvandenbossche was there more to be done here? |
jorisvandenbossche
commented
Sep 14, 2020
Thanks for the ping. I think all good. @arw2019 can you just rebase to ensure it's still all passing with latest master? |
arw2019
commented
Sep 14, 2020
@jorisvandenbossche Rebased and seeing some failures. They're ones also popping up in other, unrelated, PRs, so not sure they're to do with this patch? I'm happy to investigate, though |
jorisvandenbossche
commented
Sep 15, 2020
There are some known failures on Mac and Appveyor at the moment, so nothing to worry about for this PR. |
jorisvandenbossche
commented
Sep 15, 2020
Thanks @arw2019 ! |
arw2019
commented
Sep 15, 2020
Thanks @jorisvandenbossche for reviewing! |
This PR homogenizes error messages for mixed-type
Pandasinputs topa.Table.The message for
Pandascolumn withintfollowed bystringis nowthe same as for
doublefollowed bystring:As a side effect, this snippet [xref #5866, ARROW-7168] now throws an
ArrowInvalid(has beenFutureWarningsince 0.16):Finally, this does break a test [xref #4484, ARROW-4036] - see code comment