Skip to content

ENH: Allow read_csv(engine=pyarrow) to return ArrowExtensionArray-backed columns #47866

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from

Conversation

mroeschke
Copy link
Member

The engine="pyarrow" was added in 1.4 and is considered "experimental", so I would like opinions whether it's okay to

  1. Just change the return type to ArrowExtensionArray-backed data in 1.5
  2. Raise a warning in 1.5 that the return type will change to ArrowExtensionArray-backed in 2.0. I can't immediately think of a nice way to "opt into" this behavior in 1.5 besides calling astype() after the read_csv call.

@mroeschke mroeschke added IO CSV read_csv, to_csv Arrow pyarrow functionality labels Jul 26, 2022
@lithomas1
Copy link
Member

I would be -1 on anything but opt-in. IMO, the behavior should be consistent across all three engines. I know the read_csv is rather bloated with its many keywords, but I still think it would be worthwhile to add a new one, or co-opt use_nullable_dtypes(the proposed new keyword for the nullable EA types), especially given that Arrow EAs are still kinda new/experimental.

In general, I think there is still some discussion to be resolved around when the CSV parser should return extension array types vs numpy types(see #42973 for example).

@mroeschke
Copy link
Member Author

That's a good point and wasn't aware of expanding use_nullable_dtypes. Yeah agreed I think it would be better to leverage that keyword in a fashion like use_nullable_dtypes="pandas"|"pyarrow"|None. Closing this then.

@mroeschke mroeschke closed this Jul 29, 2022
@mroeschke mroeschke deleted the arrow/csv_arrow branch July 29, 2022 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arrow pyarrow functionality IO CSV read_csv, to_csv
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants