jorisvandenbossche commented on issue #41684:
URL: https://github.com/apache/arrow/issues/41684#issuecomment-2115400422

   > It looks like it doesn’t create a validity bitmap in this case but instead 
inserts an empty list - I would say this is a bug.
   
   I don't think that's a bug, because an empty map is a valid element for a 
map array as well.
   
   There is just not enough information in just the offsets/keys/values arrays. 
It needs additional information, which can be provided either as a separate 
mask or as nulls in the offsets.
   
   For example:
   
   ```
   In [17]: pa.MapArray.from_arrays(pa.array([0, 1, None, 1, 2], pa.int32()), 
m.keys, m.items, m.type).to_pandas()
   Out[17]: 
   0     [(a, 1.0)]
   1             []
   2           None
   3    [(b, None)]
   dtype: object
   ```
   
   (I don't find this very obvious, though .., like where you exactly need to 
put the None)
   
   The better option would be a `mask` keyword, so you could pass the result of 
`m.is_null()` to it. We have been adding a `mask` keyword to most other 
`from_arrays` methods (eg pa.ListArray.from_arrays has one, so you could take 
the workaround of first creating a list array and then convert that to a map), 
but it seems this is still missing in MapArray.from_arrays.


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