[Numpy-discussion] How to distinguish between number and string dypes
Francesc Alted
faltet at pytables.org
Thu May 27 03:27:25 EDT 2010
A Thursday 27 May 2010 05:52:22 Vincent Davis escrigué:
> How do I determine if an array's (or column in a structured array) dtype is
> a number or a string. I see how to determine the actual dtype but all I
> want to know is if it is a string or a number.
I suppose that the `.kind` attribute of dtype would help you:
In [2]: s = np.dtype("S3")
In [4]: s.kind
Out[4]: 'S'
In [5]: i = np.dtype("i4")
In [6]: i.kind
Out[6]: 'i'
In [7]: f = np.dtype("f8")
In [8]: f.kind
Out[8]: 'f'
--
Francesc Alted
More information about the NumPy-Discussion
mailing list