AttributeError: 'DatasetDict' object has no attribute 'train_test_split'
CONTRIBUTOR
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. 🙂 
2020-12-18T08:03:02Z
https://github.com/huggingface/datasets/issues/1600#issuecomment-747934322
https://api.github.com/repos/huggingface/datasets/issues/1600
MDEyOklzc3VlQ29tbWVudDc0NzkzNDMyMg==
https://api.github.com/repos/huggingface/datasets/issues/comments/747934322/reactions
2020-12-18T08:03:44Z
https://api.github.com/repos/huggingface/datasets/issues/comments/747934322
https://avatars.githubusercontent.com/u/33657802?v=4
https://api.github.com/users/SBrandeis/events{/privacy}
https://api.github.com/users/SBrandeis/followers
https://api.github.com/users/SBrandeis/following{/other_user}
https://api.github.com/users/SBrandeis/gists{/gist_id}
https://github.com/SBrandeis
SBrandeis
MDQ6VXNlcjMzNjU3ODAy
https://api.github.com/users/SBrandeis/orgs
https://api.github.com/users/SBrandeis/received_events
https://api.github.com/users/SBrandeis/repos
https://api.github.com/users/SBrandeis/starred{/owner}{/repo}
https://api.github.com/users/SBrandeis/subscriptions
User
https://api.github.com/users/SBrandeis
public
NONE
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. 
2020-12-19T01:59:26Z
https://github.com/huggingface/datasets/issues/1600#issuecomment-748401991
https://api.github.com/repos/huggingface/datasets/issues/1600
MDEyOklzc3VlQ29tbWVudDc0ODQwMTk5MQ==
https://api.github.com/repos/huggingface/datasets/issues/comments/748401991/reactions
2020-12-19T01:59:26Z
https://api.github.com/repos/huggingface/datasets/issues/comments/748401991
https://avatars.githubusercontent.com/u/5028974?v=4
https://api.github.com/users/david-waterworth/events{/privacy}
https://api.github.com/users/david-waterworth/followers
https://api.github.com/users/david-waterworth/following{/other_user}
https://api.github.com/users/david-waterworth/gists{/gist_id}
https://github.com/david-waterworth
david-waterworth
MDQ6VXNlcjUwMjg5NzQ=
https://api.github.com/users/david-waterworth/orgs
https://api.github.com/users/david-waterworth/received_events
https://api.github.com/users/david-waterworth/repos
https://api.github.com/users/david-waterworth/starred{/owner}{/repo}
https://api.github.com/users/david-waterworth/subscriptions
User
https://api.github.com/users/david-waterworth
public
CONTRIBUTOR
Closing this now
2020-12-21T07:38:58Z
https://github.com/huggingface/datasets/issues/1600#issuecomment-748818998
https://api.github.com/repos/huggingface/datasets/issues/1600
MDEyOklzc3VlQ29tbWVudDc0ODgxODk5OA==
https://api.github.com/repos/huggingface/datasets/issues/comments/748818998/reactions
2020-12-21T07:38:58Z
https://api.github.com/repos/huggingface/datasets/issues/comments/748818998
https://avatars.githubusercontent.com/u/33657802?v=4
https://api.github.com/users/SBrandeis/events{/privacy}
https://api.github.com/users/SBrandeis/followers
https://api.github.com/users/SBrandeis/following{/other_user}
https://api.github.com/users/SBrandeis/gists{/gist_id}
https://github.com/SBrandeis
SBrandeis
MDQ6VXNlcjMzNjU3ODAy
https://api.github.com/users/SBrandeis/orgs
https://api.github.com/users/SBrandeis/received_events
https://api.github.com/users/SBrandeis/repos
https://api.github.com/users/SBrandeis/starred{/owner}{/repo}
https://api.github.com/users/SBrandeis/subscriptions
User
https://api.github.com/users/SBrandeis
public
NONE
> ```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?
2021-05-19T17:22:38Z
https://github.com/huggingface/datasets/issues/1600#issuecomment-844310741
https://api.github.com/repos/huggingface/datasets/issues/1600
MDEyOklzc3VlQ29tbWVudDg0NDMxMDc0MQ==
https://api.github.com/repos/huggingface/datasets/issues/comments/844310741/reactions
2021-05-19T17:22:38Z
https://api.github.com/repos/huggingface/datasets/issues/comments/844310741
https://avatars.githubusercontent.com/u/33121271?v=4
https://api.github.com/users/nehanawalkar/events{/privacy}
https://api.github.com/users/nehanawalkar/followers
https://api.github.com/users/nehanawalkar/following{/other_user}
https://api.github.com/users/nehanawalkar/gists{/gist_id}
https://github.com/nehanawalkar
nehanawalkar
MDQ6VXNlcjMzMTIxMjcx
https://api.github.com/users/nehanawalkar/orgs
https://api.github.com/users/nehanawalkar/received_events
https://api.github.com/users/nehanawalkar/repos
https://api.github.com/users/nehanawalkar/starred{/owner}{/repo}
https://api.github.com/users/nehanawalkar/subscriptions
User
https://api.github.com/users/nehanawalkar
public
NONE
dataset = load_dataset('csv', data_files=['files/datasets/dataset.csv'])
dataset = dataset['train']
dataset = dataset.train_test_split(test_size=0.1)
2021-06-15T11:25:46Z
https://github.com/huggingface/datasets/issues/1600#issuecomment-861417549
https://api.github.com/repos/huggingface/datasets/issues/1600
MDEyOklzc3VlQ29tbWVudDg2MTQxNzU0OQ==
https://api.github.com/repos/huggingface/datasets/issues/comments/861417549/reactions
2021-06-15T11:25:46Z
https://api.github.com/repos/huggingface/datasets/issues/comments/861417549
https://avatars.githubusercontent.com/u/18459508?v=4
https://api.github.com/users/sadidul012/events{/privacy}
https://api.github.com/users/sadidul012/followers
https://api.github.com/users/sadidul012/following{/other_user}
https://api.github.com/users/sadidul012/gists{/gist_id}
https://github.com/sadidul012
sadidul012
MDQ6VXNlcjE4NDU5NTA4
https://api.github.com/users/sadidul012/orgs
https://api.github.com/users/sadidul012/received_events
https://api.github.com/users/sadidul012/repos
https://api.github.com/users/sadidul012/starred{/owner}{/repo}
https://api.github.com/users/sadidul012/subscriptions
User
https://api.github.com/users/sadidul012
public
NONE
!curl -L "https://app.roboflow.com/ds/YQYgzFyKns?key=f0IwaEetrr" > roboflow.zip; unzip roboflow.zip; rm roboflow.zip

from datasets import load_dataset

dataset = load_dataset("imagefolder", data_dir="/content/")
dataset["train"][0]

dataset["train"][-1]

train_ds = load_dataset("imagefolder", data_dir="/content/train/")
test_ds = load_dataset("imagefolder", data_dir="/content/test/")
val_ds = load_dataset("imagefolder", data_dir="/content/valid/")

train_ds.features

and i got error 
AttributeError                            Traceback (most recent call last)
[<ipython-input-6-289222110c33>](https://localhost:8080/#) in <cell line: 1>()
----> 1 train_ds.features

AttributeError: 'DatasetDict' object has no attribute 'features'
2023-05-02T03:11:03Z
https://github.com/huggingface/datasets/issues/1600#issuecomment-1530809786
https://api.github.com/repos/huggingface/datasets/issues/1600
IC_kwDODunzps5bPk26
https://api.github.com/repos/huggingface/datasets/issues/comments/1530809786/reactions
2023-05-02T03:11:03Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1530809786
https://avatars.githubusercontent.com/u/124749343?v=4
https://api.github.com/users/dhikaputri/events{/privacy}
https://api.github.com/users/dhikaputri/followers
https://api.github.com/users/dhikaputri/following{/other_user}
https://api.github.com/users/dhikaputri/gists{/gist_id}
https://github.com/dhikaputri
dhikaputri
U_kgDOB2-GHw
https://api.github.com/users/dhikaputri/orgs
https://api.github.com/users/dhikaputri/received_events
https://api.github.com/users/dhikaputri/repos
https://api.github.com/users/dhikaputri/starred{/owner}{/repo}
https://api.github.com/users/dhikaputri/subscriptions
User
https://api.github.com/users/dhikaputri
public
NONE
This has been closed, you should open a new issue describing what your problem is.
2023-05-02T21:48:15Z
https://github.com/huggingface/datasets/issues/1600#issuecomment-1532198092
https://api.github.com/repos/huggingface/datasets/issues/1600
IC_kwDODunzps5bU3zM
https://api.github.com/repos/huggingface/datasets/issues/comments/1532198092/reactions
2023-05-02T21:48:15Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1532198092
https://avatars.githubusercontent.com/u/5028974?v=4
https://api.github.com/users/david-waterworth/events{/privacy}
https://api.github.com/users/david-waterworth/followers
https://api.github.com/users/david-waterworth/following{/other_user}
https://api.github.com/users/david-waterworth/gists{/gist_id}
https://github.com/david-waterworth
david-waterworth
MDQ6VXNlcjUwMjg5NzQ=
https://api.github.com/users/david-waterworth/orgs
https://api.github.com/users/david-waterworth/received_events
https://api.github.com/users/david-waterworth/repos
https://api.github.com/users/david-waterworth/starred{/owner}{/repo}
https://api.github.com/users/david-waterworth/subscriptions
User
https://api.github.com/users/david-waterworth
public
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'