@@ -135,7 +135,7 @@ def num_columns(self) -> Dict[str, int]:
135135
136136 @property
137137 def num_rows (self ) -> Dict [str , int ]:
138- """Number of rows in each split of the dataset (same as :func:`datasets.Dataset.__len__`) .
138+ """Number of rows in each split of the dataset.
139139
140140 Example:
141141
@@ -222,7 +222,7 @@ def unique(self, column: str) -> Dict[str, List]:
222222
223223 Args:
224224 column (`str`):
225- column name (list all the column names with [`~datasets.Dataset .column_names`])
225+ column name (list all the column names with [`~datasets.DatasetDict .column_names`])
226226
227227 Returns:
228228 Dict[`str`, `list`]: Dictionary of unique elements in the given column.
@@ -268,15 +268,12 @@ def cast(self, features: Features) -> "DatasetDict":
268268 Cast the dataset to a new set of features.
269269 The transformation is applied to all the datasets of the dataset dictionary.
270270
271- You can also remove a column using [`Dataset.map`] with `feature` but `cast`
272- is in-place (doesn't copy the data to a new dataset) and is thus faster.
273-
274271 Args:
275272 features ([`Features`]):
276273 New features to cast the dataset to.
277274 The name and order of the fields in the features must match the current column names.
278275 The type of the data must also be convertible from one type to the other.
279- For non-trivial conversion, e.g. `string` <-> `ClassLabel` you should use [`~Dataset .map`] to update the Dataset .
276+ For non-trivial conversion, e.g. `string` <-> `ClassLabel` you should use [`~DatasetDict .map`] to update the dataset .
280277
281278 Example:
282279
@@ -334,19 +331,22 @@ def remove_columns(self, column_names: Union[str, List[str]]) -> "DatasetDict":
334331
335332 The transformation is applied to all the splits of the dataset dictionary.
336333
337- You can also remove a column using [`Dataset .map`] with `remove_columns` but the present method
338- is in-place ( doesn't copy the data to a new dataset) and is thus faster.
334+ You can also remove a column using [`~DatasetDict .map`] with `remove_columns` but the present method
335+ doesn't copy the data of the remaining columns and is thus faster.
339336
340337 Args:
341338 column_names (`Union[str, List[str]]`):
342339 Name of the column(s) to remove.
343340
341+ Returns:
342+ [`DatasetDict`]: A copy of the dataset object without the columns to remove.
343+
344344 Example:
345345
346346 ```py
347347 >>> from datasets import load_dataset
348348 >>> ds = load_dataset("rotten_tomatoes")
349- >>> ds.remove_columns("label")
349+ >>> ds = ds .remove_columns("label")
350350 DatasetDict({
351351 train: Dataset({
352352 features: ['text'],
@@ -371,7 +371,7 @@ def rename_column(self, original_column_name: str, new_column_name: str) -> "Dat
371371 Rename a column in the dataset and move the features associated to the original column under the new column name.
372372 The transformation is applied to all the datasets of the dataset dictionary.
373373
374- You can also rename a column using [`~Dataset .map`] with `remove_columns` but the present method:
374+ You can also rename a column using [`~DatasetDict .map`] with `remove_columns` but the present method:
375375 - takes care of moving the original features under the new column name.
376376 - doesn't copy the data to a new dataset and is thus much faster.
377377
@@ -386,7 +386,7 @@ def rename_column(self, original_column_name: str, new_column_name: str) -> "Dat
386386 ```py
387387 >>> from datasets import load_dataset
388388 >>> ds = load_dataset("rotten_tomatoes")
389- >>> ds.rename_column("label", "label_new")
389+ >>> ds = ds .rename_column("label", "label_new")
390390 DatasetDict({
391391 train: Dataset({
392392 features: ['text', 'label_new'],
0 commit comments