Skip to content

COMPAT: prepare for pandas 3.0 string dtype #493

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

Merged
merged 11 commits into from
Apr 30, 2025

Conversation

jorisvandenbossche
Copy link
Member

@jorisvandenbossche jorisvandenbossche commented Nov 7, 2024

Testing with the string dtype enabled (pd.options.future.infer_string = True, or PANDAS_FUTURE_INFER_STRING=1 set as environment variable).

@jorisvandenbossche jorisvandenbossche marked this pull request as ready for review April 28, 2025 07:51
@jorisvandenbossche jorisvandenbossche added this to the 0.11.0 milestone Apr 28, 2025
@jorisvandenbossche
Copy link
Member Author

All green now, would like to include this in the upcoming 0.11 release

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 ! Overall this looks good, just a few minor comments.

Can you please add a changelog entry?

try:
res = pd.to_datetime(ser, utc=True, **datetime_kwargs)
except Exception:
pass

if res.dtype != "object":
if res.dtype.kind == "M":
Copy link
Member

Choose a reason for hiding this comment

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

To confirm, this is the dtype code for datetime with millisecond precision? Perhaps add a comment to indicate the full dtype name here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not specifically millisecond resolution, but just datetime64 in general (the numpy datetime64 dtype's short character name is "M").

But will add a comment

@@ -1214,7 +1234,11 @@ def test_write_None_string_column(tmp_path, use_arrow):
assert filename.exists()

result_gdf = read_dataframe(filename, use_arrow=use_arrow)
assert result_gdf.object_col.dtype == object
assert (
Copy link
Member

Choose a reason for hiding this comment

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

Could this assert be folded into the conditional below (with a corresponding else)?

assert output_gdf["mixed"][idx] is None
else:
assert output_gdf["mixed"][idx] == str(value)
# mixed values as object dtype are currently written as strings
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# mixed values as object dtype are currently written as strings
# non-null mixed values as object dtype are currently written as strings

Copy link
Member Author

Choose a reason for hiding this comment

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

(also null values are written as string dtype, but preserving the fact they are null)

@jorisvandenbossche jorisvandenbossche merged commit e5ac209 into geopandas:main Apr 30, 2025
25 checks passed
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.

2 participants