Modify add_column() to optionally accept a FeatureType as param
CONTRIBUTOR
Requesting review @lhoestq 
I will also update the docs if this looks good.
2024-09-08T11:10:16Z
https://github.com/huggingface/datasets/pull/7143#issuecomment-2336644332
https://api.github.com/repos/huggingface/datasets/issues/7143
IC_kwDODunzps6LRlzs
https://api.github.com/repos/huggingface/datasets/issues/comments/2336644332/reactions
2024-09-08T11:10:16Z
https://api.github.com/repos/huggingface/datasets/issues/comments/2336644332
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
MEMBER
Cool ! maybe you can rename the argument `feature` and with type `FeatureType` ? This way it would work the same way as `.cast_column()` ?
2024-09-09T10:36:08Z
https://github.com/huggingface/datasets/pull/7143#issuecomment-2337755682
https://api.github.com/repos/huggingface/datasets/issues/7143
IC_kwDODunzps6LV1Ii
https://api.github.com/repos/huggingface/datasets/issues/comments/2337755682/reactions
2024-09-09T10:36:08Z
https://api.github.com/repos/huggingface/datasets/issues/comments/2337755682
https://avatars.githubusercontent.com/u/42851186?v=4
https://api.github.com/users/lhoestq/events{/privacy}
https://api.github.com/users/lhoestq/followers
https://api.github.com/users/lhoestq/following{/other_user}
https://api.github.com/users/lhoestq/gists{/gist_id}
https://github.com/lhoestq
lhoestq
MDQ6VXNlcjQyODUxMTg2
https://api.github.com/users/lhoestq/orgs
https://api.github.com/users/lhoestq/received_events
https://api.github.com/users/lhoestq/repos
https://api.github.com/users/lhoestq/starred{/owner}{/repo}
https://api.github.com/users/lhoestq/subscriptions
User
https://api.github.com/users/lhoestq
public
CONTRIBUTOR
@lhoestq Since there is no way to get a `pyarrow.Schema` from a `FeatureType`, I had to go via `Features`. How does this look?
2024-09-10T15:07:46Z
https://github.com/huggingface/datasets/pull/7143#issuecomment-2341194390
https://api.github.com/repos/huggingface/datasets/issues/7143
IC_kwDODunzps6Li8qW
https://api.github.com/repos/huggingface/datasets/issues/comments/2341194390/reactions
2024-09-10T15:07:46Z
https://api.github.com/repos/huggingface/datasets/issues/comments/2341194390
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
NONE
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/datasets/pr_7143). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
2024-09-10T15:34:05Z
https://github.com/huggingface/datasets/pull/7143#issuecomment-2341276366
https://api.github.com/repos/huggingface/datasets/issues/7143
IC_kwDODunzps6LjQrO
https://api.github.com/repos/huggingface/datasets/issues/comments/2341276366/reactions
2024-09-10T15:34:05Z
https://api.github.com/repos/huggingface/datasets/issues/comments/2341276366
https://avatars.githubusercontent.com/u/99929124?v=4
https://api.github.com/users/HuggingFaceDocBuilderDev/events{/privacy}
https://api.github.com/users/HuggingFaceDocBuilderDev/followers
https://api.github.com/users/HuggingFaceDocBuilderDev/following{/other_user}
https://api.github.com/users/HuggingFaceDocBuilderDev/gists{/gist_id}
https://github.com/HuggingFaceDocBuilderDev
HuggingFaceDocBuilderDev
U_kgDOBfTMJA
https://api.github.com/users/HuggingFaceDocBuilderDev/orgs
https://api.github.com/users/HuggingFaceDocBuilderDev/received_events
https://api.github.com/users/HuggingFaceDocBuilderDev/repos
https://api.github.com/users/HuggingFaceDocBuilderDev/starred{/owner}{/repo}
https://api.github.com/users/HuggingFaceDocBuilderDev/subscriptions
User
https://api.github.com/users/HuggingFaceDocBuilderDev
public
CONTRIBUTOR
@lhoestq done!
2024-09-11T12:14:18Z
https://github.com/huggingface/datasets/pull/7143#issuecomment-2343503536
https://api.github.com/repos/huggingface/datasets/issues/7143
IC_kwDODunzps6Lrwaw
https://api.github.com/repos/huggingface/datasets/issues/comments/2343503536/reactions
2024-09-11T12:14:18Z
https://api.github.com/repos/huggingface/datasets/issues/comments/2343503536
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
CONTRIBUTOR
@lhoestq anything pending on this?
2024-09-13T09:25:17Z
https://github.com/huggingface/datasets/pull/7143#issuecomment-2348472571
https://api.github.com/repos/huggingface/datasets/issues/7143
IC_kwDODunzps6L-tj7
https://api.github.com/repos/huggingface/datasets/issues/comments/2348472571/reactions
2024-09-13T09:25:17Z
https://api.github.com/repos/huggingface/datasets/issues/comments/2348472571
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
Fix #7142.

**Before (Add + Cast)**:

```
from datasets import load_dataset, Value
ds = load_dataset("rotten_tomatoes", split="test")
lst = [i for i in range(len(ds))]

ds = ds.add_column("new_col", lst)
# Assigns int64 to new_col by default
print(ds.features)

ds = ds.cast_column("new_col", Value(dtype="uint16", id=None))
print(ds.features)
```


**Before (Numpy Workaround)**:

```
from datasets import load_dataset
import numpy as np
ds = load_dataset("rotten_tomatoes", split="test")
lst = [i for i in range(len(ds))]

ds = ds.add_column("new_col", np.array(lst, dtype=np.uint16))
print(ds.features)
```

**After**:
```
from datasets import load_dataset, Value
ds = load_dataset("rotten_tomatoes", split="test")
lst = [i for i in range(len(ds))]
val = Value(dtype="uint16", id=None))
ds = ds.add_column("new_col", lst, feature=val)
print(ds.features)
```