Produce a column projection for this IO layer. Given a list of required output columns, this method returns the projected layer.
(self, columns)
| 450 | return self._columns |
| 451 | |
| 452 | def project_columns(self, columns): |
| 453 | """Produce a column projection for this IO layer. |
| 454 | Given a list of required output columns, this method |
| 455 | returns the projected layer. |
| 456 | """ |
| 457 | from dask.dataframe.io.utils import DataFrameIOFunction |
| 458 | |
| 459 | columns = list(columns) |
| 460 | |
| 461 | if self.columns is None or set(self.columns).issuperset(columns): |
| 462 | # Apply column projection in IO function. |
| 463 | # Must satisfy `DataFrameIOFunction` protocol |
| 464 | if isinstance(self.io_func, DataFrameIOFunction): |
| 465 | io_func = self.io_func.project_columns(columns) |
| 466 | else: |
| 467 | io_func = self.io_func |
| 468 | |
| 469 | layer = DataFrameIOLayer( |
| 470 | (self.label or "subset") + "-" + tokenize(self.name, columns), |
| 471 | columns, |
| 472 | self.inputs, |
| 473 | io_func, |
| 474 | label=self.label, |
| 475 | produces_tasks=self.produces_tasks, |
| 476 | annotations=self.annotations, |
| 477 | ) |
| 478 | return layer |
| 479 | else: |
| 480 | # Default behavior |
| 481 | return self |
| 482 | |
| 483 | def __repr__(self): |
| 484 | return f"DataFrameIOLayer<name='{self.name}', n_parts={len(self.inputs)}, columns={self.columns}>" |
nothing calls this directly
no test coverage detected