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

Function test_table_drop_columns

python/pyarrow/tests/test_table.py:1776–1793  ·  view source on GitHub ↗

drop one or more columns given labels

(cls)

Source from the content-addressed store, hash-verified

1774 ]
1775)
1776def test_table_drop_columns(cls):
1777 """ drop one or more columns given labels"""
1778 a = pa.array(range(5))
1779 b = pa.array([-10, -5, 0, 5, 10])
1780 c = pa.array(range(5, 10))
1781
1782 table = cls.from_arrays([a, b, c], names=('a', 'b', 'c'))
1783 t2 = table.drop_columns(['a', 'b'])
1784 t3 = table.drop_columns('a')
1785
1786 exp_t2 = cls.from_arrays([c], names=('c',))
1787 assert exp_t2.equals(t2)
1788 exp_t3 = cls.from_arrays([b, c], names=('b', 'c',))
1789 assert exp_t3.equals(t3)
1790
1791 # -- raise KeyError if column not in Table
1792 with pytest.raises(KeyError, match="Column 'd' not found"):
1793 table.drop_columns(['d'])
1794
1795
1796def test_table_drop():

Callers

nothing calls this directly

Calls 2

equalsMethod · 0.80
arrayMethod · 0.45

Tested by

no test coverage detected