haixuanTao opened a new issue, #37496:
URL: https://github.com/apache/arrow/issues/37496

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   When using pyarrow, calling `py.array` on a `dict` creates a array of the 
dict keys. In case the dict keys are string it's going to be converted into a 
list of string, same things if the keys are int it's going to be a list of 
ints. 
   
   In my opinion, it would be better to map it into a StructArray. In the same 
way that when it's called encapsulated in a `list`. See the following example:
   ```python
   >>> import pyarrow as pa
   >>> pa.array({"a":1, "b":2})
   <pyarrow.lib.StringArray object at 0x7f4bacb8e500>
   [
     "a",
     "b"
   ]
   >>> pa.array([{"a":1, "b":2}])
   <pyarrow.lib.StructArray object at 0x7f4bacb8e560>
   -- is_valid: all not null
   -- child 0 type: int64
     [
       1
     ]
   -- child 1 type: int64
     [
       2
     ]
   ```
   
   Alternative could be to raise a warning or an error, as the encapsulation 
can easily be forgotten.
   
   See: https://github.com/dora-rs/dora/pull/346
   
   ### Component(s)
   
   Python


-- 
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]

Reply via email to