What does datatype "S7" mean
Question:
Use the following command, the s.dtype
will be ‘S7’, what does ‘S7’ means?
I have Googled, but only a Japanese website with failed link
I have read the Document in numpy, no luck
>>> strings = np.array([b'cat', b'dog', b'chicken', b'horse', b'goat'])
>>> s = strings[[0,1]]
>>> s.dtype
dtype('S7')
Thanks for your help
Answers:
The dtype object describes how the bytes in the fixed-size block of memory corresponding to an array item should be interpreted. It describes different aspects of the data such as:
- Type of data
- Size of the data
- Byte order of the data etc.
Here, ‘S7’ means that the object is of type string and it’s size(no. of bytes) is 7. You can confirm this by calling the ‘itemsize’ attribute for s.
>>>s.itemsize
7
Use the following command, the s.dtype
will be ‘S7’, what does ‘S7’ means?
I have Googled, but only a Japanese website with failed link
I have read the Document in numpy, no luck
>>> strings = np.array([b'cat', b'dog', b'chicken', b'horse', b'goat'])
>>> s = strings[[0,1]]
>>> s.dtype
dtype('S7')
Thanks for your help
The dtype object describes how the bytes in the fixed-size block of memory corresponding to an array item should be interpreted. It describes different aspects of the data such as:
- Type of data
- Size of the data
- Byte order of the data etc.
Here, ‘S7’ means that the object is of type string and it’s size(no. of bytes) is 7. You can confirm this by calling the ‘itemsize’ attribute for s.
>>>s.itemsize
7