Implement to_csv for Dataset
CONTRIBUTOR
@lhoestq I stumbled upon an interesting failure when adding tests for CSV serialization of `ArrayXD` features (see the failing unit tests in the CI)

It's due to the fact that booleans cannot be converted from arrow format to numpy without copy: https://arrow.apache.org/docs/python/generated/pyarrow.Array.html#pyarrow.Array.to_numpy
2021-02-18T11:58:26Z
https://github.com/huggingface/datasets/pull/1887#issuecomment-781293228
https://api.github.com/repos/huggingface/datasets/issues/1887
MDEyOklzc3VlQ29tbWVudDc4MTI5MzIyOA==
https://api.github.com/repos/huggingface/datasets/issues/comments/781293228/reactions
2021-02-18T12:03:12Z
https://api.github.com/repos/huggingface/datasets/issues/comments/781293228
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
MEMBER
Good catch ! I must be able to fix that one by allowing copies for this kind of arrays.
This is the kind of surprise you get sometimes when playing with arrow x)
2021-02-18T13:18:26Z
https://github.com/huggingface/datasets/pull/1887#issuecomment-781337435
https://api.github.com/repos/huggingface/datasets/issues/1887
MDEyOklzc3VlQ29tbWVudDc4MTMzNzQzNQ==
https://api.github.com/repos/huggingface/datasets/issues/comments/781337435/reactions
2021-02-18T13:18:26Z
https://api.github.com/repos/huggingface/datasets/issues/comments/781337435
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
MEMBER
Raising this error for booleans was introduced in https://issues.apache.org/jira/browse/ARROW-2871?jql=text%20~%20%22boolean%20to_numpy%22 without much explanations unfortunately.
So "no copy" only works for primitive types - except booleans.
This is confirmed in the source code at https://github.com/wesm/arrow/blob/c07b9b48cf3e0bbbab493992a492ae47e5b04cad/python/pyarrow/array.pxi#L621

I'm opening a PR to allow copies for booleans...
2021-02-18T16:08:37Z
https://github.com/huggingface/datasets/pull/1887#issuecomment-781453213
https://api.github.com/repos/huggingface/datasets/issues/1887
MDEyOklzc3VlQ29tbWVudDc4MTQ1MzIxMw==
https://api.github.com/repos/huggingface/datasets/issues/comments/781453213/reactions
2021-02-18T16:08:37Z
https://api.github.com/repos/huggingface/datasets/issues/comments/781453213
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
MEMBER
I just merged the fix for boolean ArrayXD, feel free to merge from master to see if it fixes the ci :)
2021-02-18T17:10:53Z
https://github.com/huggingface/datasets/pull/1887#issuecomment-781497264
https://api.github.com/repos/huggingface/datasets/issues/1887
MDEyOklzc3VlQ29tbWVudDc4MTQ5NzI2NA==
https://api.github.com/repos/huggingface/datasets/issues/comments/781497264/reactions
2021-02-18T17:10:53Z
https://api.github.com/repos/huggingface/datasets/issues/comments/781497264
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 unfirtunately, arrays of strings (or any other non-primitive type) require a copy too

A list of primitive types can be found here: https://github.com/wesm/arrow/blob/c07b9b48cf3e0bbbab493992a492ae47e5b04cad/python/pyarrow/types.pxi#L821

pyarrow provides a `is_primitive` function to check whether a type is primitive , I used it to set `zero_copy_only`

Also, `PandasArrayExtensionArray.isna` was using `numpy.isnan` which fails for arrays of strings. I replaced it with `pandas.isna`. Let me know what you think! :) 
2021-02-18T18:53:43Z
https://github.com/huggingface/datasets/pull/1887#issuecomment-781562603
https://api.github.com/repos/huggingface/datasets/issues/1887
MDEyOklzc3VlQ29tbWVudDc4MTU2MjYwMw==
https://api.github.com/repos/huggingface/datasets/issues/comments/781562603/reactions
2021-02-18T18:53:43Z
https://api.github.com/repos/huggingface/datasets/issues/comments/781562603
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
cc @thomwolf 

`to_csv` supports passing either a file path or a *binary* file object
The writing is batched to avoid loading the whole table in memory