-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
is_string_like
returns True for numpy object
arrays
#7725
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
Comments
In what context is this a problem? A numpy object array of str objects is very string like [he says having flash-backs to MATLAB days]. |
I use For the moment, in my project, I overcame the issue by forcing the columns related to the points to have again the I understand this may be an unexpected behaviour of
does not generate any type of errors or warnings. It simply has no effect.
instead, generates an error, hence It seemed reasonable, however, to open an issue here, due to the fact that assuming the generation of some errors in such operations, causes the function to consider strings something which is not. |
That sounds like pandas is doing something wrong (as one of the big advantages of panadas over numpy is to have heterogeneous columns) That test has no effect because you are adding an empty string, if you do In [5]: np.array(['1','2'], dtype=object) + 'b'
Out[5]:
array(['1b', '2b'], dtype=object) what is doing is clearer (the In the second case, you get In [4]: np.array(['1','2'], dtype=str) + ''
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-4-1ccaacc2525d> in <module>()
----> 1 np.array(['1','2'], dtype=str) + ''
TypeError: ufunc 'add' did not contain a loop with signature matching types dtype('<U1') dtype('<U1') dtype('<U1') Because instead of holding the values as python string objects (which know how to add with another string and is just a black-box to numpy) it is holding the values as fixed length c-strings and the dispatch mechanism in numpy does not know how to deal with this. |
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug summary
Function
is_string_like
returns True for numpyobject
arraysCode for reproduction
Actual outcome
Expected outcome
The problem is that the line 707
obj + ''
inis_string_like
does not generate an exception with such numpy array.Matplotlib version
The text was updated successfully, but these errors were encountered: