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: numpy.char funcs error with string array citing non-string array. #41973

Open
2 of 3 tasks
attack68 opened this issue Jun 12, 2021 · 0 comments
Open
2 of 3 tasks
Labels
Bug Compat pandas objects compatability with Numpy or Python functions Strings String extension data type and string data

Comments

@attack68
Copy link
Contributor

  • I have checked that this issue has not already been reported - briefly

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


s = Series(["a", "b"])
np.char.find(s, "b")
# or np.capitalize(s)

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-9-a924fee0248d> in <module>
----> 1 np.char.capitalize(s)

<__array_function__ internals> in capitalize(*args, **kwargs)

~/envPandas38/lib/python3.8/site-packages/numpy/core/defchararray.py in capitalize(a)
    414     """
    415     a_arr = numpy.asarray(a)
--> 416     return _vec_string(a_arr, a_arr.dtype, 'capitalize')
    417 
    418 

TypeError: string operation on non-string array

Problem description

This fails even though s is composed of strings and even things like s.str s.astype(str), dtype=str make no difference.

Expected Output

numpy string functions should work

pandas master as of 12 jun 21.
numpy 1.20.3

@attack68 attack68 added Bug Needs Triage Issue that has not been reviewed by a pandas team member Strings String extension data type and string data labels Jun 12, 2021
@mzeitlin11 mzeitlin11 added Compat pandas objects compatability with Numpy or Python functions and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Jul 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Compat pandas objects compatability with Numpy or Python functions Strings String extension data type and string data
Projects
None yet
Development

No branches or pull requests

2 participants