You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Python] Scalar constructors should be callable #31648
Currently, to create a Scalar instance you must call the pa.scalar factory function. This works fine for the simplest types, but not for more elaborate ones.
For example, in C++ it is trivial to create a ListScalar from the embedded std::shared_ptr<Array>. But not in Python:
>>> arr = pa.array(["abc", "def", "ghi"])
>>> pa.scalar(arr)
Traceback (mostrecentcalllast):
...
ArrowInvalid: Couldnotconvert <pyarrow.lib.StringArrayobjectat0x7f79ab490880>
[
"abc", "def", "ghi"
] with type pyarrow.lib.StringArray: did not recognize Python value type when inferring an Arrow data type
>>> pa.scalar(arr, type=pa.list_(arr.type))
Traceback (most recent call last):
...
ArrowTypeError: Expected bytes, got a 'pyarrow.lib.StringScalar' object
This issue has been marked as stale because it has had no activity in the past 365 days. Please remove the stale label or comment below, or this issue will be closed in 14 days. If this improvement is still desired but has no current owner, please add the 'Status: needs champion' label.
Activity
asfimport commentedon Apr 20, 2022
Antoine Pitrou / @pitrou:
cc @AlenkaF @raulcd
asfimport commentedon Apr 21, 2022
Joris Van den Bossche / @jorisvandenbossche:
For this specific example, the
pa.scalar(..)factory function also seems to work?asfimport commentedon Apr 21, 2022
Antoine Pitrou / @pitrou:
It does not if you pass an existing PyArrow array:
asfimport commentedon Apr 21, 2022
Joris Van den Bossche / @jorisvandenbossche:
Ah, yes. Now, that relates to the issue that
pa.array(..)also does not accept pyarrow arrays as scalars, see ARROW-5295github-actions commentedon Mar 27, 2026
This issue has been marked as stale because it has had no activity in the past 365 days. Please remove the stale label or comment below, or this issue will be closed in 14 days. If this improvement is still desired but has no current owner, please add the 'Status: needs champion' label.