Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why numpy data type kind returns void when it was created as float64?

Tags:

python

numpy

I have this code:

>>> d = np.dtype([("pos", np.float64, 3)])
>>> d[0].kind
'V'

Why does it return 'V' instead of 'f'? In the full code, I need to know if the field corresponds to an integer, float, string...

like image 783
Abel Gutiérrez Avatar asked Sep 06 '25 19:09

Abel Gutiérrez


1 Answers

d[0].kind does not return 'f' because it is not a floating-point dtype: it is a structured dtype with a floating point base.

There are several other attributes of structured dtypes that you might be able to inspect depending on your particular goal. For example:

>>> d[0].base
dtype('float64')
>>> d[0].subdtype[0].kind
'f'
like image 92
jakevdp Avatar answered Sep 09 '25 19:09

jakevdp