drin commented on issue #14116:
URL: https://github.com/apache/arrow/issues/14116#issuecomment-1255601819

   As far as I can tell, yes only struct arrays take elements as a dictionary, 
not a map array.
   
   Just for completeness, though, I wanted to mention that you can use 
`dict.items()` to get a list of tuples. I realize that I don't know how complex 
your actual structure is or how many you have, etc; so, this is just if you 
have a stronger preference for map arrays than struct arrays.
   
   ```python
       # tags_ref is a generator, so maybe not too much performance impact?
       # could also consider wrapping the dict in a class that delegates all 
calls except when accessing 'tags'?
       # some_row = {'id': 1, 'tags': {'tag1': 'value1', 'tag2': 'value2'}}
       tags_ref = (
           {
                'id'  : some_row.get('id')
               ,'tags': list(some_row.get('tags').items())
           }
           for some_row in tags_updated
       )
   
       table = Table.from_pylist(mapping=list(tags_ref), schema=pyarrow_schema)
   ```


-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to