drin commented on issue #14116:
URL: https://github.com/apache/arrow/issues/14116#issuecomment-1248572896
I don't know very much about parquet, though I do understand Arrow.
If I understand the question correctly, you want to know how to go from a
`dict` to a `MapArray`?
What I tried to show was that the `mapping` param of `from_pylist` seems to
take a list of rows, where each row can be a dictionary mapping a column name
to a value for that column. In that sense, you could just have a function that
transforms a `dict` to a list of tuples. Logically this should be easy, though
I'm not sure how important performance is for you.
```python
# this dictionary represents a single row
tags_updated = {
"id": 1,
"tags": {
"tag1": "value1",
"tag2": "value2"
}
}
# extract and convert the value for the "tags" column
tags_as_map = [
(tag_key, tag_val)
for tag_key, tag_val in tags_updated.get('tags', {}).items()
]
# then we replace the value
tags_updated['tags'] = tags_as_map
# then we can use "from_pylist" as usual
table = Table.from_pylist(mapping=[tags_updated], 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]