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

Source from the content-addressed store, hash-verified

2597
2598
2599def test_table_repr_to_string():
2600 # Schema passed explicitly
2601 schema = pa.schema([pa.field('c0', pa.int16(),
2602 metadata={'key': 'value'}),
2603 pa.field('c1', pa.int32())],
2604 metadata={b'foo': b'bar'})
2605
2606 tab = pa.table([pa.array([1, 2, 3, 4], type='int16'),
2607 pa.array([10, 20, 30, 40], type='int32')], schema=schema)
2608 assert str(tab) == """pyarrow.Table
2609c0: int16
2610c1: int32
2611----
2612c0: [[1,2,3,4]]
2613c1: [[10,20,30,40]]"""
2614
2615 assert tab.to_string(show_metadata=True) == """\
2616pyarrow.Table
2617c0: int16
2618 -- field metadata --
2619 key: 'value'
2620c1: int32
2621-- schema metadata --
2622foo: 'bar'"""
2623
2624 assert tab.to_string(preview_cols=5) == """\
2625pyarrow.Table
2626c0: int16
2627c1: int32
2628----
2629c0: [[1,2,3,4]]
2630c1: [[10,20,30,40]]"""
2631
2632 assert tab.to_string(preview_cols=1) == """\
2633pyarrow.Table
2634c0: int16
2635c1: int32
2636----
2637c0: [[1,2,3,4]]
2638..."""
2639
2640
2641def 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