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

Function test_table_from_pydict_schema

python/pyarrow/tests/test_table.py:2488–2504  ·  view source on GitHub ↗
(data, klass)

Source from the content-addressed store, hash-verified

2486 (([[''], ['foo', 'bar']], [[4.5], [5., None]]), pa.chunked_array),
2487])
2488def test_table_from_pydict_schema(data, klass):
2489 # passed schema is source of truth for the columns
2490
2491 data = OrderedDict([('strs', klass(data[0])), ('floats', klass(data[1]))])
2492
2493 # schema has columns not present in data -> error
2494 schema = pa.schema([('strs', pa.utf8()), ('floats', pa.float64()),
2495 ('ints', pa.int64())])
2496 with pytest.raises(KeyError, match='ints'):
2497 pa.Table.from_pydict(data, schema=schema)
2498
2499 # data has columns not present in schema -> ignored
2500 schema = pa.schema([('strs', pa.utf8())])
2501 table = pa.Table.from_pydict(data, schema=schema)
2502 assert table.num_columns == 1
2503 assert table.schema == schema
2504 assert table.column_names == ['strs']
2505
2506
2507@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 1

schemaMethod · 0.45

Tested by

no test coverage detected