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

Source from the content-addressed store, hash-verified

2705
2706
2707def test_table_repr_to_string():
2708 # Schema passed explicitly
2709 schema = pa.schema([pa.field('c0', pa.int16(),
2710 metadata={'key': 'value'}),
2711 pa.field('c1', pa.int32())],
2712 metadata={b'foo': b'bar'})
2713
2714 tab = pa.table([pa.array([1, 2, 3, 4], type='int16'),
2715 pa.array([10, 20, 30, 40], type='int32')], schema=schema)
2716 assert str(tab) == """pyarrow.Table
2717c0: int16
2718c1: int32
2719----
2720c0: [[1,2,3,4]]
2721c1: [[10,20,30,40]]"""
2722
2723 assert tab.to_string(show_metadata=True) == """\
2724pyarrow.Table
2725c0: int16
2726 -- field metadata --
2727 key: 'value'
2728c1: int32
2729-- schema metadata --
2730foo: 'bar'"""
2731
2732 assert tab.to_string(preview_cols=5) == """\
2733pyarrow.Table
2734c0: int16
2735c1: int32
2736----
2737c0: [[1,2,3,4]]
2738c1: [[10,20,30,40]]"""
2739
2740 assert tab.to_string(preview_cols=1) == """\
2741pyarrow.Table
2742c0: int16
2743c1: int32
2744----
2745c0: [[1,2,3,4]]
2746..."""
2747
2748
2749def 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