wjones127 commented on issue #37496:
URL: https://github.com/apache/arrow/issues/37496#issuecomment-1701693881
> And so you could potentially do the same thing in arrow and map it to a
StructArray format.
That's a whole different thing, since it implies the values are arrays. That
would be:
```python
>>> pa.array({'x': [1, 2], 'y': ['a', 'b']})
struct array
child x: int64 [1, 2]
child y: utf8 ["a", "b"]
```
FWIW the `Table` constructor function `pa.table()` supports dictionaries
like that, and they can be converted to struct array if that's what's needed.
> Ok, just found out you can use:
> pa.scalar(dict)
> for scalar type.
Yes, for singular values, use `pa.scalar()`.
> So, I guess, raising an error for pa.array(dict) avoiding silent
conversion should be the way to go.
Still not sure we need to error. The same "silent" conversion will happen
for anything that is iterable, and I don't think we want to carve out a whole
bunch of data structures just because we think users didn't intentionally pass
them. It's well understood that a dictionary is iterable over its keys, so I
don't think it's that unexpected that it would produce an array consisting of
its keys when passed to `pa.array()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]