Convert this block into the provided batch format. Args: batch_format: The batch format to convert this block to. Returns: This block formatted as the provided batch format.
(self, batch_format: Optional[str])
| 491 | return self.to_block() |
| 492 | |
| 493 | def to_batch_format(self, batch_format: Optional[str]) -> DataBatch: |
| 494 | """Convert this block into the provided batch format. |
| 495 | |
| 496 | Args: |
| 497 | batch_format: The batch format to convert this block to. |
| 498 | |
| 499 | Returns: |
| 500 | This block formatted as the provided batch format. |
| 501 | """ |
| 502 | if batch_format is None: |
| 503 | return self.to_block() |
| 504 | elif batch_format == "default" or batch_format == "native": |
| 505 | return self.to_default() |
| 506 | elif batch_format == "pandas": |
| 507 | return self.to_pandas() |
| 508 | elif batch_format == "pyarrow": |
| 509 | return self.to_arrow() |
| 510 | elif batch_format == "numpy": |
| 511 | return self.to_numpy() |
| 512 | elif batch_format == "cudf": |
| 513 | return self.to_cudf() |
| 514 | else: |
| 515 | raise ValueError( |
| 516 | f"The batch format must be one of {VALID_BATCH_FORMATS}, got: " |
| 517 | f"{batch_format}" |
| 518 | ) |
| 519 | |
| 520 | def size_bytes(self) -> int: |
| 521 | """Return the approximate size in bytes of this block.""" |
no test coverage detected