-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
GH-21761: [Python] accept pyarrow values / scalars in constructor functions ? #34658
Conversation
This seems to work? |
Yes, it is working for sequences with
Oh yes, that is true (missed it).
Agree, will add a test 👍 |
result = _ndarray_to_array(values, mask, type, c_from_pandas, safe, | ||
pool) | ||
except ArrowInvalid as err: | ||
if "Scalar" in str(err): |
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.
Relying on a substring within the error message seems a bit hacky. Is there any other way to check by chance?
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.
Oh yeah, it's very hacky! =)
I have tried multiple ways of catching the specific ArrowInvalid
error as others are expected here also, but all of them have some issue. Can try to remember them all and list them, but Joris advised me to go into the Python C++ code and use ConvertToSequenceAndInferSize
so this will be changed. I should convert this PR into a draft to make this clear.
Thank you for reviewing!
Closing this PR in favour of #36162. |
Rationale for this change
Currently,
pyarrow.array
doesn't accept list of pyarrow Scalars and this PR adds a check to allow that.