Skip to content

fix: pd.Series in pandas>=3 does not preserve object dtype metadata #10564

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

Open
wants to merge 37 commits into
base: main
Choose a base branch
from

Conversation

ilan-gold
Copy link
Contributor

@ilan-gold ilan-gold commented Jul 24, 2025

Only opening this here ATM to see that CI runs through. The diff is otherwise as advertised in #10559 (comment)

@github-actions github-actions bot added topic-indexing topic-arrays related to flexible array support labels Jul 24, 2025
@dcherian
Copy link
Contributor

This seems like an upstream bug. Can you open an issue there please?

@ilan-gold
Copy link
Contributor Author

Done!

@@ -216,7 +217,16 @@ def _possibly_convert_objects(values):
* pd.Timedelta
"""
as_series = pd.Series(values.ravel(), copy=False)
# For why we need this behavior: https://github.com/pandas-dev/pandas/issues/61938
Copy link
Contributor

@dcherian dcherian Jul 29, 2025

Choose a reason for hiding this comment

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

let's add a little more please "pandas will convert to str if possible; preserve object dtype metadata in all other cases"

we should update the docstring to say strings too.

result = np.asarray(as_series).reshape(values.shape)
if (
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move this after the writable bit below instead?

@dcherian dcherian added the run-upstream Run upstream CI label Jul 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-upstream Run upstream CI topic-arrays related to flexible array support topic-indexing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

⚠️ Nightly upstream-dev CI failed ⚠️
2 participants