Allow opposite of remove_columns on Dataset and DatasetDict
{'login': 'hollance', 'id': 346853, 'node_id': 'MDQ6VXNlcjM0Njg1Mw==', 'avatar_url': 'https://avatars.githubusercontent.com/u/346853?v=4', 'gravatar_id': '', 'url': 'https://api.github.com/users/hollance', 'html_url': 'https://github.com/hollance', 'followers_url': 'https://api.github.com/users/hollance/followers', 'following_url': 'https://api.github.com/users/hollance/following{/other_user}', 'gists_url': 'https://api.github.com/users/hollance/gists{/gist_id}', 'starred_url': 'https://api.github.com/users/hollance/starred{/owner}{/repo}', 'subscriptions_url': 'https://api.github.com/users/hollance/subscriptions', 'organizations_url': 'https://api.github.com/users/hollance/orgs', 'repos_url': 'https://api.github.com/users/hollance/repos', 'events_url': 'https://api.github.com/users/hollance/events{/privacy}', 'received_events_url': 'https://api.github.com/users/hollance/received_events', 'type': 'User', 'site_admin': False}
[{'id': 1935892871, 'node_id': 'MDU6TGFiZWwxOTM1ODkyODcx', 'url': 'https://api.github.com/repos/huggingface/datasets/labels/enhancement', 'name': 'enhancement', 'color': 'a2eeef', 'default': True, 'description': 'New feature or request'}, {'id': 1935892877, 'node_id': 'MDU6TGFiZWwxOTM1ODkyODc3', 'url': 'https://api.github.com/repos/huggingface/datasets/labels/good%20first%20issue', 'name': 'good first issue', 'color': '7057ff', 'default': True, 'description': 'Good for newcomers'}]
[]
Hi! I agree it would be nice to have a method like that. Instead of `keep_columns`, we can name it `select_columns` to be more aligned with PyArrow's naming convention (`pa.Table.select`). Hi, I am a newbie to open source and would like to contribute. @mariosasko can I take up this issue ? Hey, I also want to work on this issue I am a newbie to open source.  This sounds related to https://github.com/huggingface/datasets/issues/5474

I'm fine with `select_columns`, or we could also override `select` to also accept a list of columns maybe ? @lhoestq, I am planning to add a member function to the dataset class to perform the selection operation. Do you think its the right way to proceed? or there is a better option ? Unless @mariosasko thinks otherwise, I think it can go in `Dataset.select()` :)
Though some parameters like keep_in_memory, indices_cache_file_name or writer_batch_size wouldn't when selecting columns, so we would need to update the docstring as well If someone wants to give it a shot, feel free to comment `#self-assign` and it will assign the issue to you.

Feel free to ping us here if you have questions or if we can help :) I would rather have this functionality as a separate method. IMO it's always better to be explicit than to have an API where a single method can do different/uncorrelated things (somewhat reminds me of Pandas, and there is probably a good reason why PyArrow is more rigid in this aspect). In the end I also think it would be nice to have it as a separate method, this way we can also have it for `IterableDataset` (which can't have `select` for indices)
### Feature request

In this blog post https://huggingface.co/blog/audio-datasets, I noticed the following code:

```python
COLUMNS_TO_KEEP = ["text", "audio"]
all_columns = gigaspeech["train"].column_names
columns_to_remove = set(all_columns) - set(COLUMNS_TO_KEEP)

gigaspeech = gigaspeech.remove_columns(columns_to_remove)
```

This kind of thing happens a lot when you don't need to keep all columns from the dataset. It would be more convenient (and less error prone) if you could just write:

```python
gigaspeech = gigaspeech.keep_columns(["text", "audio"])
```

Internally, `keep_columns` could still call `remove_columns`, but it expresses more clearly what the user's intent is.

### Motivation

Less code to write for the user of the dataset.

### Your contribution

-
{'url': 'https://api.github.com/repos/huggingface/datasets/issues/5468/reactions', 'total_count': 0, '+1': 0, '-1': 0, 'laugh': 0, 'hooray': 0, 'confused': 0, 'heart': 0, 'rocket': 0, 'eyes': 0}