-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Closed
Description
Original ticket http://projects.scipy.org/numpy/ticket/1814 on 2011-04-29 by @jonovik, assigned to unknown.
Is there a reason why Unicode strings are not accepted as field names for record arrays?
>>> np.dtype([("a", int)])
dtype([('a', '<i4')])
>>> np.dtype([(u"a", int)])
TypeError: data type not understood
A workaround is .encode("ascii").
>>> np.dtype([(u"a".encode("ascii"), int)])
dtype([('a', '<i4')])
It is okay for the type specification to be Unicode.
>>> np.dtype([("a", u"S2")])
dtype([('a', '|S2')])}}}
I came across this while building a record array from data in a Microsoft Excel spreadsheet using pythoncom and win32com. Converting to ascii isn't too much of a hassle, but maybe it wouldn't be difficult to allow Unicode strings as field names?