Skip to content
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

BUG: fix conversion of WKB to geometries in case of using ArrowDtype and missing values #321

Merged
merged 4 commits into from
Oct 30, 2023

Conversation

jorisvandenbossche
Copy link
Member

@jorisvandenbossche jorisvandenbossche commented Oct 28, 2023

Closes #319

Comment on lines 279 to 281
if PANDAS_GE_20 and wkb_values.dtype != object:
# for example ArrowDtype will otherwise create numpy array with pd.NA
wkb_values = wkb_values.to_numpy(na_value=None)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to this only conditionally, because otherwise it would impact performance for the default case (where the binary pyarrow array was already converted to an object dtype column with None values. When specifying an na_value in that case, it would check for missing values and overwrite them with None, which be an unnecessary operation).

Checking for "not object dtype" instead of explicitly checking for "is ArrowDtype" felt the most future proof (eg when pandas adds a proper binary dtype (using Arrow under the hood), it might have the same issue but without being an ArrowDtype instance)

Copy link
Member

@brendan-ward brendan-ward left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jorisvandenbossche !

Can you please add a changelog entry for 0.7.2 and update the release date (also, I'm not available to do a release today)

@brendan-ward brendan-ward merged commit e648c0f into geopandas:main Oct 30, 2023
18 checks passed
@jorisvandenbossche jorisvandenbossche deleted the pandas-arrow-dtype branch January 6, 2024 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: Expected bytes or string, got NAType when using Arrow-pandas types_mapper
3 participants