- class lance.LanceOperation.Project(lance.LanceOperation.BaseOperation)
Operation that project columns. Use this operator for drop column or rename/swap column.
- schema¶
The lance schema of the new dataset.
- Type:
LanceSchema
Examples
Use the projece operator to swap column:
>>> import lance >>> import pyarrow as pa >>> import pyarrow.compute as pc >>> from lance.schema import LanceSchema >>> table = pa.table({"a": [1, 2], "b": ["a", "b"], "b1": ["c", "d"]}) >>> dataset = lance.write_dataset(table, "example") >>> dataset.to_table().to_pandas() a b b1 0 1 a c 1 2 b d >>> >>> ## rename column `b` into `b0` and rename b1 into `b` >>> table = pa.table({"a": [3, 4], "b0": ["a", "b"], "b": ["c", "d"]}) >>> lance_schema = LanceSchema.from_pyarrow(table.schema) >>> operation = lance.LanceOperation.Project(lance_schema) >>> dataset = lance.LanceDataset.commit("example", operation, read_version=1) >>> dataset.to_table().to_pandas() a b0 b 0 1 a c 1 2 b d
Public members¶
- __repr__()
Return repr(self).
- schema : LanceSchema