Rename columns in the dataset. Examples: >>> import ray >>> ds = ray.data.read_parquet("s3://anonymous@ray-example-data/iris.parquet") >>> ds.schema() Column Type ------ ---- sepal.length double
(
self,
names: Union[List[str], Dict[str, str]],
*,
concurrency: Optional[Union[int, Tuple[int, int], Tuple[int, int, int]]] = None,
**ray_remote_args,
)
| 1279 | |
| 1280 | @PublicAPI(api_group=BT_API_GROUP) |
| 1281 | def rename_columns( |
| 1282 | self, |
| 1283 | names: Union[List[str], Dict[str, str]], |
| 1284 | *, |
| 1285 | concurrency: Optional[Union[int, Tuple[int, int], Tuple[int, int, int]]] = None, |
| 1286 | **ray_remote_args, |
| 1287 | ): |
| 1288 | """Rename columns in the dataset. |
| 1289 | |
| 1290 | Examples: |
| 1291 | |
| 1292 | >>> import ray |
| 1293 | >>> ds = ray.data.read_parquet("s3://anonymous@ray-example-data/iris.parquet") |
| 1294 | >>> ds.schema() |
| 1295 | Column Type |
| 1296 | ------ ---- |
| 1297 | sepal.length double |
| 1298 | sepal.width double |
| 1299 | petal.length double |
| 1300 | petal.width double |
| 1301 | variety string |
| 1302 | |
| 1303 | You can pass a dictionary mapping old column names to new column names. |
| 1304 | |
| 1305 | >>> ds.rename_columns({"variety": "category"}).schema() |
| 1306 | Column Type |
| 1307 | ------ ---- |
| 1308 | sepal.length double |
| 1309 | sepal.width double |
| 1310 | petal.length double |
| 1311 | petal.width double |
| 1312 | category string |
| 1313 | |
| 1314 | Or you can pass a list of new column names. |
| 1315 | |
| 1316 | >>> ds.rename_columns( |
| 1317 | ... ["sepal_length", "sepal_width", "petal_length", "petal_width", "variety"] |
| 1318 | ... ).schema() |
| 1319 | Column Type |
| 1320 | ------ ---- |
| 1321 | sepal_length double |
| 1322 | sepal_width double |
| 1323 | petal_length double |
| 1324 | petal_width double |
| 1325 | variety string |
| 1326 | |
| 1327 | Args: |
| 1328 | names: A dictionary that maps old column names to new column names, or a |
| 1329 | list of new column names. |
| 1330 | concurrency: The maximum number of Ray workers to use concurrently. |
| 1331 | **ray_remote_args: Additional resource requirements to request from |
| 1332 | Ray (e.g., num_gpus=1 to request GPUs for the map tasks). See |
| 1333 | :func:`ray.remote` for details. |
| 1334 | |
| 1335 | Returns: |
| 1336 | A new :class:`Dataset` with the specified columns renamed. |
| 1337 | """ # noqa: E501 |
| 1338 |
no test coverage detected