Specifying datatype when adding a column to a dataset.
CONTRIBUTOR
#self-assign
2024-09-08T07:35:25Z
https://github.com/huggingface/datasets/issues/7142#issuecomment-2336581886
https://api.github.com/repos/huggingface/datasets/issues/7142
IC_kwDODunzps6LRWj-
https://api.github.com/repos/huggingface/datasets/issues/comments/2336581886/reactions
2024-09-08T07:35:25Z
https://api.github.com/repos/huggingface/datasets/issues/comments/2336581886
https://avatars.githubusercontent.com/u/20443618?v=4
https://api.github.com/users/varadhbhatnagar/events{/privacy}
https://api.github.com/users/varadhbhatnagar/followers
https://api.github.com/users/varadhbhatnagar/following{/other_user}
https://api.github.com/users/varadhbhatnagar/gists{/gist_id}
https://github.com/varadhbhatnagar
varadhbhatnagar
MDQ6VXNlcjIwNDQzNjE4
https://api.github.com/users/varadhbhatnagar/orgs
https://api.github.com/users/varadhbhatnagar/received_events
https://api.github.com/users/varadhbhatnagar/repos
https://api.github.com/users/varadhbhatnagar/starred{/owner}{/repo}
https://api.github.com/users/varadhbhatnagar/subscriptions
User
https://api.github.com/users/varadhbhatnagar
public
### Feature request

There should be a way to specify the datatype of a column in `datasets.add_column()`. 

### Motivation

To specify a custom datatype, we have to use `datasets.add_column()` followed by `datasets.cast_column()` which is slow for large datasets. Another workaround is to pass a `numpy.array()` of desired type to the `datasets.add_column()` function.

IMO this functionality should be natively supported.

https://discuss.huggingface.co/t/add-column-with-a-particular-type-in-datasets/95674



### Your contribution

I can submit a PR for this.