AttributeError: 'DatasetDict' object has no attribute 'train_test_split'
{'login': 'david-waterworth', 'id': 5028974, 'node_id': 'MDQ6VXNlcjUwMjg5NzQ=', 'avatar_url': 'https://avatars.githubusercontent.com/u/5028974?v=4', 'gravatar_id': '', 'url': 'https://api.github.com/users/david-waterworth', 'html_url': 'https://github.com/david-waterworth', 'followers_url': 'https://api.github.com/users/david-waterworth/followers', 'following_url': 'https://api.github.com/users/david-waterworth/following{/other_user}', 'gists_url': 'https://api.github.com/users/david-waterworth/gists{/gist_id}', 'starred_url': 'https://api.github.com/users/david-waterworth/starred{/owner}{/repo}', 'subscriptions_url': 'https://api.github.com/users/david-waterworth/subscriptions', 'organizations_url': 'https://api.github.com/users/david-waterworth/orgs', 'repos_url': 'https://api.github.com/users/david-waterworth/repos', 'events_url': 'https://api.github.com/users/david-waterworth/events{/privacy}', 'received_events_url': 'https://api.github.com/users/david-waterworth/received_events', 'type': 'User', 'site_admin': False}
[{'id': 1935892912, 'node_id': 'MDU6TGFiZWwxOTM1ODkyOTEy', 'url': 'https://api.github.com/repos/huggingface/datasets/labels/question', 'name': 'question', 'color': 'd876e3', 'default': True, 'description': 'Further information is requested'}]
[]
Hi @david-waterworth!

As indicated in the error message, `load_dataset("csv")` returns a `DatasetDict` object, which is mapping of `str` to `Dataset` objects. I believe in this case the behavior is to return a `train` split with all the data.
`train_test_split` is a method of the `Dataset` object, so you will need to do something like this:
```python
dataset_dict = load_dataset(`'csv', data_files='data.txt')
dataset = dataset_dict['split name, eg train']
dataset.train_test_split(test_size=0.1)
```

Please let me know if this helps. 🙂  Thanks, that's working - the same issue also tripped me up with training. 

I also agree https://github.com/huggingface/datasets/issues/767 would be a useful addition.  Closing this now > ```python
> dataset_dict = load_dataset(`'csv', data_files='data.txt')
> dataset = dataset_dict['split name, eg train']
> dataset.train_test_split(test_size=0.1)
> ```

I am getting error like
KeyError: 'split name, eg train'
Could you please tell me how to solve this? dataset = load_dataset('csv', data_files=['files/datasets/dataset.csv'])
dataset = dataset['train']
dataset = dataset.train_test_split(test_size=0.1)
The following code fails with "'DatasetDict' object has no attribute 'train_test_split'" - am I doing something wrong?
```
from datasets import load_dataset
dataset = load_dataset('csv', data_files='data.txt')
dataset = dataset.train_test_split(test_size=0.1)
```

> AttributeError: 'DatasetDict' object has no attribute 'train_test_split'
{'url': 'https://api.github.com/repos/huggingface/datasets/issues/1600/reactions', 'total_count': 0, '+1': 0, '-1': 0, 'laugh': 0, 'hooray': 0, 'confused': 0, 'heart': 0, 'rocket': 0, 'eyes': 0}