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: Passing a stringdtype array to np.where can lose string data #26420

Closed
ngoldbaum opened this issue May 10, 2024 · 0 comments · Fixed by #26436
Closed

BUG: Passing a stringdtype array to np.where can lose string data #26420

ngoldbaum opened this issue May 10, 2024 · 0 comments · Fixed by #26436
Labels

Comments

@ngoldbaum
Copy link
Member

ngoldbaum commented May 10, 2024

Describe the issue:

Similar to #26147 and #26317 it looks like np.where should be doing a copy instead of a view for StringDType.

Reproduce the code example:

import numpy as np
a = np.array(["a"*25, "b", np.nan], dtype=np.dtypes.StringDType(na_object=np.nan))
print(repr(np.where(a, a, a)))

Result:

# prints:
array(['', 'b', nan], dtype=StringDType(na_object=nan))

# should print:
array(['aaaaaaaaaaaaaaaaaaaaaaaaa', 'b', nan],
      dtype=StringDType(na_object=nan))

Python and NumPy Versions:

Current main branch, python 3.12.2.

Runtime Environment:

No response

Context for the issue:

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant