MCPcopy Create free account
hub / github.com/apache/arrow / test_table_maps_as_pydicts

Function test_table_maps_as_pydicts

python/pyarrow/tests/test_table.py:2015–2032  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2013
2014
2015def test_table_maps_as_pydicts():
2016 arrays = [
2017 pa.array(
2018 [{'x': 1, 'y': 2}, {'z': 3}],
2019 type=pa.map_(pa.string(), pa.int32())
2020 )
2021 ]
2022 table = pa.Table.from_arrays(arrays, names=['a'])
2023
2024 table_dict = table.to_pydict(maps_as_pydicts="strict")
2025 assert 'a' in table_dict
2026 column_list = table_dict['a']
2027 assert len(column_list) == 2
2028 assert column_list == [{'x': 1, 'y': 2}, {'z': 3}]
2029
2030 table_list = table.to_pylist(maps_as_pydicts="strict")
2031 assert len(table_list) == 2
2032 assert table_list == [{'a': {'x': 1, 'y': 2}}, {'a': {'z': 3}}]
2033
2034
2035def test_concat_tables():

Callers

nothing calls this directly

Calls 3

lenFunction · 0.85
arrayMethod · 0.45
stringMethod · 0.45

Tested by

no test coverage detected