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:1954–1971  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1952
1953
1954def test_table_maps_as_pydicts():
1955 arrays = [
1956 pa.array(
1957 [{'x': 1, 'y': 2}, {'z': 3}],
1958 type=pa.map_(pa.string(), pa.int32())
1959 )
1960 ]
1961 table = pa.Table.from_arrays(arrays, names=['a'])
1962
1963 table_dict = table.to_pydict(maps_as_pydicts="strict")
1964 assert 'a' in table_dict
1965 column_list = table_dict['a']
1966 assert len(column_list) == 2
1967 assert column_list == [{'x': 1, 'y': 2}, {'z': 3}]
1968
1969 table_list = table.to_pylist(maps_as_pydicts="strict")
1970 assert len(table_list) == 2
1971 assert table_list == [{'a': {'x': 1, 'y': 2}}, {'a': {'z': 3}}]
1972
1973
1974def 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