numpy – How to interpret Python output dtype=

numpy – How to interpret Python output dtype=

It is fully explained in the manual:

Several kinds of strings can be converted. Recognized strings can be prepended with > (big-endian), < (little-endian), or = (hardware-native, the default), to specify the byte order.

[…]

The first character specifies the kind of data and the remaining characters specify the number of bytes per item, except for Unicode, where it is interpreted as the number of characters. The item size must correspond to an existing type, or an error will be raised. The supported kinds are

[…]

U        Unicode string

So, a little-endian Unicode string of 32 characters.

dtype=<U32 is a little-endian 32 character string.

The documentation on dtypes goes into more depth about each of the character.

U Unicode string

Several kinds of strings can be converted. Recognized strings can be prepended with > (big-endian), < (little-endian), or = (hardware-native, the default), to specify the byte order.

Examples:

dt = np.dtype(f8)   # 64-bit floating-point number
dt = np.dtype(c16)  # 128-bit complex floating-point number
dt = np.dtype(a25)  # 25-length zero-terminated bytes
dt = np.dtype(U25)  # 25-character string```

numpy – How to interpret Python output dtype=

Leave a Reply

Your email address will not be published.