Python Forum
How to resolve numpy ValueError: dtype.descr - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to resolve numpy ValueError: dtype.descr (/thread-29112.html)



How to resolve numpy ValueError: dtype.descr - Py_veeran - Aug-18-2020

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