| [ Web Proxy ] |
| Viewing: https://arrow.apache.org/docs/python/generated/pyarrow.map_.html | [Back] [Original] |
Section Navigation
Create MapType instance from key and item data types or fields.
DataTypeExamples
Create an instance of MapType:
>>> import pyarrow as pa
>>> pa.map_(pa.string(), pa.int32())
MapType(map<string, int32>)
>>> pa.map_(pa.string(), pa.int32(), keys_sorted=True)
MapType(map<string, int32, keys_sorted>)
Use MapType to create an array:
>>> data = [[{'key': 'a', 'value': 1}, {'key': 'b', 'value': 2}], [{'key': 'c', 'value': 3}]]
>>> pa.array(data, type=pa.map_(pa.string(), pa.int32(), keys_sorted=True))
<pyarrow.lib.MapArray object at ...>
[
keys:
[
"a",
"b"
]
values:
[
1,
2
],
keys:
[
"c"
]
values:
[
3
]
]
Copyright 2016-2026 Apache Software Foundation.
Apache Arrow, Arrow, Apache, the Apache logo, and the Apache Arrow project logo are either registered trademarks or trademarks of The Apache Software Foundation in the United States and other countries.
Created using Sphinx 9.1.0.
Built with the PyData Sphinx Theme 0.20.0.
| Web Proxy Viewer | New URL | Original Page |