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

Function test_table_add_column

python/pyarrow/tests/test_table.py:1721–1741  ·  view source on GitHub ↗
(cls)

Source from the content-addressed store, hash-verified

1719 ]
1720)
1721def test_table_add_column(cls):
1722 data = [
1723 pa.array(range(5)),
1724 pa.array([-10, -5, 0, 5, 10]),
1725 pa.array(range(5, 10))
1726 ]
1727 table = cls.from_arrays(data, names=('a', 'b', 'c'))
1728
1729 new_field = pa.field('d', data[1].type)
1730 t2 = table.add_column(3, new_field, data[1])
1731 t3 = table.append_column(new_field, data[1])
1732
1733 expected = cls.from_arrays(data + [data[1]],
1734 names=('a', 'b', 'c', 'd'))
1735 assert t2.equals(expected)
1736 assert t3.equals(expected)
1737
1738 t4 = table.add_column(0, new_field, data[1])
1739 expected = cls.from_arrays([data[1]] + data,
1740 names=('d', 'a', 'b', 'c'))
1741 assert t4.equals(expected)
1742
1743
1744@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 3

equalsMethod · 0.80
arrayMethod · 0.45
fieldMethod · 0.45

Tested by

no test coverage detected