[Numpy-discussion] How to distinguish between number and string dypes

Vincent Davis vincent at vincentdavis.net
Thu May 27 11:40:13 EDT 2010


On Thu, May 27, 2010 at 8:39 AM, Keith Goodman <kwgoodman at gmail.com> wrote:

> To see if it is a number could you use something like:
>
> np.issubdtype(a.dtype, float) or np.issubdtype(a.dtype, int) or
> np.issubdtype(a.dtype, complex)
>
> And for string:
>
> np.issubdtype(a.dtype, str)
>

These are valid but what I don't like is that I need to know the list of
possible number types. Basically I don't like a test that fails because I
didn't know about a dtype. For string It is ok, the universe of is either
string or not string. Maybe this is as good as it gets.

I guess my use case is that I want to be sure I can perform math on the
values. So maybe I should just do someting like
"numpy.lib._iotools._is_string_like"
but "_is_number_like", Maybe there is such and I missed it. If not there
should be.

Vincent



_______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>

  *Vincent Davis
720-301-3003 *
vincent at vincentdavis.net
 my blog <http://vincentdavis.net> |
LinkedIn<http://www.linkedin.com/in/vincentdavis>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20100527/e72f4a35/attachment.html>


More information about the NumPy-Discussion mailing list