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

Function test_table_factory_function

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

Source from the content-addressed store, hash-verified

2631
2632@pytest.mark.pandas
2633def test_table_factory_function():
2634 import pandas as pd
2635
2636 # Put in wrong order to make sure that lines up with schema
2637 d = OrderedDict([('b', ['a', 'b', 'c']), ('a', [1, 2, 3])])
2638
2639 d_explicit = {'b': pa.array(['a', 'b', 'c'], type='string'),
2640 'a': pa.array([1, 2, 3], type='int32')}
2641
2642 schema = pa.schema([('a', pa.int32()), ('b', pa.string())])
2643
2644 df = pd.DataFrame(d)
2645 table1 = pa.table(df)
2646 table2 = pa.Table.from_pandas(df)
2647 assert table1.equals(table2)
2648 table1 = pa.table(df, schema=schema)
2649 table2 = pa.Table.from_pandas(df, schema=schema)
2650 assert table1.equals(table2)
2651
2652 table1 = pa.table(d_explicit)
2653 table2 = pa.Table.from_pydict(d_explicit)
2654 assert table1.equals(table2)
2655
2656 # schema coerces type
2657 table1 = pa.table(d, schema=schema)
2658 table2 = pa.Table.from_pydict(d, schema=schema)
2659 assert table1.equals(table2)
2660
2661
2662def test_table_factory_function_args():

Callers

nothing calls this directly

Calls 4

equalsMethod · 0.80
arrayMethod · 0.45
schemaMethod · 0.45
stringMethod · 0.45

Tested by

no test coverage detected