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

Function test_table_repr_to_string

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

Source from the content-addressed store, hash-verified

2644
2645
2646def test_table_repr_to_string():
2647 # Schema passed explicitly
2648 schema = pa.schema([pa.field('c0', pa.int16(),
2649 metadata={'key': 'value'}),
2650 pa.field('c1', pa.int32())],
2651 metadata={b'foo': b'bar'})
2652
2653 tab = pa.table([pa.array([1, 2, 3, 4], type='int16'),
2654 pa.array([10, 20, 30, 40], type='int32')], schema=schema)
2655 assert str(tab) == """pyarrow.Table
2656c0: int16
2657c1: int32
2658----
2659c0: [[1,2,3,4]]
2660c1: [[10,20,30,40]]"""
2661
2662 assert tab.to_string(show_metadata=True) == """\
2663pyarrow.Table
2664c0: int16
2665 -- field metadata --
2666 key: 'value'
2667c1: int32
2668-- schema metadata --
2669foo: 'bar'"""
2670
2671 assert tab.to_string(preview_cols=5) == """\
2672pyarrow.Table
2673c0: int16
2674c1: int32
2675----
2676c0: [[1,2,3,4]]
2677c1: [[10,20,30,40]]"""
2678
2679 assert tab.to_string(preview_cols=1) == """\
2680pyarrow.Table
2681c0: int16
2682c1: int32
2683----
2684c0: [[1,2,3,4]]
2685..."""
2686
2687
2688def test_table_repr_to_string_ellipsis():

Callers

nothing calls this directly

Calls 4

schemaMethod · 0.45
fieldMethod · 0.45
arrayMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected