drop one or more columns given labels
(cls)
| 1774 | ] |
| 1775 | ) |
| 1776 | def 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 | |
| 1796 | def test_table_drop(): |