我有一个dtype对象e
:
>>> e
dtype([('cards', 'O'), ('store', 'O'), ('march', 'O'),
('fam', 'O'), ('cup', 'O'), ('sex', 'O'), ('educ', 'O'),
('age', 'O'), ('handedness', 'O')])
我想把它变成一个字符串数组:
np.array(['cards','store','march','fam','cup','sex','educ','age','handedness'])
有没有办法将此对象转换为如图所示的数组?
我在这里尝试过这些建议:
How to convert a Numpy 2D array with object dtype to a regular 2D array of floats
但是我收到了错误:
ValueError Traceback (most recent call last)
<ipython-input-160-dc37d6f17f2f> in <module>()
----> 1 np.array(list(e[:, 1]), dtype=str)
ValueError: Field key must be an integer, string, or unicode.