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

Project(schema: LanceSchema)

Initialize self. See help(type(self)) for accurate signature.

__repr__()

Return repr(self).

__eq__(other)

Return self==value.

schema : LanceSchema