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: astype to string modifying input array inplace #51073

Merged
merged 5 commits into from
Feb 1, 2023

Conversation

phofl
Copy link
Member

@phofl phofl commented Jan 30, 2023

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

inferring is faster than copying in all cases.

@phofl phofl mentioned this pull request Jan 30, 2023
5 tasks
# modifying input inplace
inferred = lib.infer_dtype(scalars, skipna=False)
if inferred != "string":
copy = True
result = lib.ensure_string_array(scalars, na_value=libmissing.NA, copy=copy)
Copy link
Member

Choose a reason for hiding this comment

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

can we do this fix in ensure_string_array? ive been hoping to simplify it to make it always take an ndarray.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep sure, was not sure if this was intended or not. Moved to Cython and improved performance as well

@mroeschke mroeschke added Dtype Conversions Unexpected or buggy dtype conversions Strings String extension data type and string data labels Jan 31, 2023
@mroeschke mroeschke added this to the 2.0 milestone Feb 1, 2023
@jorisvandenbossche jorisvandenbossche merged commit 337faf3 into pandas-dev:main Feb 1, 2023
@jorisvandenbossche
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Strings String extension data type and string data
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants