Code example for dataset.add_column() does not reflect correct way to use function
CONTRIBUTOR
Hi @shaily99 

Thanks for pointing this out — you're absolutely right!

The current example in the docstring for add_column() implies in-place modification, which is misleading since add_column() actually returns a new dataset.
2025-06-27T05:15:22Z
https://github.com/huggingface/datasets/issues/7611#issuecomment-3011701955
https://api.github.com/repos/huggingface/datasets/issues/7611
IC_kwDODunzps6zguzD
https://api.github.com/repos/huggingface/datasets/issues/comments/3011701955/reactions
2025-06-27T05:15:22Z
https://api.github.com/repos/huggingface/datasets/issues/comments/3011701955
https://avatars.githubusercontent.com/u/142811259?v=4
https://api.github.com/users/ArjunJagdale/events{/privacy}
https://api.github.com/users/ArjunJagdale/followers
https://api.github.com/users/ArjunJagdale/following{/other_user}
https://api.github.com/users/ArjunJagdale/gists{/gist_id}
https://github.com/ArjunJagdale
ArjunJagdale
U_kgDOCIMgew
https://api.github.com/users/ArjunJagdale/orgs
https://api.github.com/users/ArjunJagdale/received_events
https://api.github.com/users/ArjunJagdale/repos
https://api.github.com/users/ArjunJagdale/starred{/owner}{/repo}
https://api.github.com/users/ArjunJagdale/subscriptions
User
https://api.github.com/users/ArjunJagdale
public
CONTRIBUTOR
#self-assign

2025-06-27T05:15:32Z
https://github.com/huggingface/datasets/issues/7611#issuecomment-3011702238
https://api.github.com/repos/huggingface/datasets/issues/7611
IC_kwDODunzps6zgu3e
https://api.github.com/repos/huggingface/datasets/issues/comments/3011702238/reactions
2025-06-27T05:15:32Z
https://api.github.com/repos/huggingface/datasets/issues/comments/3011702238
https://avatars.githubusercontent.com/u/142811259?v=4
https://api.github.com/users/ArjunJagdale/events{/privacy}
https://api.github.com/users/ArjunJagdale/followers
https://api.github.com/users/ArjunJagdale/following{/other_user}
https://api.github.com/users/ArjunJagdale/gists{/gist_id}
https://github.com/ArjunJagdale
ArjunJagdale
U_kgDOCIMgew
https://api.github.com/users/ArjunJagdale/orgs
https://api.github.com/users/ArjunJagdale/received_events
https://api.github.com/users/ArjunJagdale/repos
https://api.github.com/users/ArjunJagdale/starred{/owner}{/repo}
https://api.github.com/users/ArjunJagdale/subscriptions
User
https://api.github.com/users/ArjunJagdale
public
https://github.com/huggingface/datasets/blame/38d4d0e11e22fdbc4acf373d2421d25abeb43439/src/datasets/arrow_dataset.py#L5925C10-L5925C10

The example seems to suggest that dataset.add_column() can add column inplace, however, this is wrong -- it cannot. It returns a new dataset with the column added to it.