Create a column accessor for the given column
(col: BlockColumn)
| 890 | |
| 891 | @staticmethod |
| 892 | def for_column(col: BlockColumn) -> "BlockColumnAccessor": |
| 893 | """Create a column accessor for the given column""" |
| 894 | _check_pyarrow_version() |
| 895 | |
| 896 | import pandas as pd |
| 897 | |
| 898 | if isinstance(col, pa.Array) or isinstance(col, pa.ChunkedArray): |
| 899 | from ray.data._internal.arrow_block import ArrowBlockColumnAccessor |
| 900 | |
| 901 | return ArrowBlockColumnAccessor(col) |
| 902 | elif isinstance(col, pd.Series): |
| 903 | from ray.data._internal.pandas_block import PandasBlockColumnAccessor |
| 904 | |
| 905 | return PandasBlockColumnAccessor(col) |
| 906 | else: |
| 907 | raise TypeError( |
| 908 | f"Expected either a pandas.Series or pyarrow.Array " |
| 909 | f"(ChunkedArray) (got {type(col)})" |
| 910 | ) |
| 911 | |
| 912 | |
| 913 | def _get_group_boundaries_sorted_numpy(columns: list[np.ndarray]) -> np.ndarray: |