Python Forum

Full Version: How to resolve numpy ValueError: dtype.descr
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I have created a numpy array and would like to change the order. While using I am getting below error.

import numpy as np
a = np.array([1,2,3])
b = np.array([(1.5,2,3), (4,5,6)], dtype = [('col1','<f8'),('col2','<i4'),('col3','<i4')])
names_list=['col2','col1','col3']
c=b[names_list]

print(c.dtype.descr)

Error:
lib\site-packages\numpy\core\_internal.py", line 114, in _array_descr raise ValueError( ValueError: dtype.descr is not defined for types with overlapping or out-of-order fields