ภาพรวม
ใช้ numpy.typename() คืนคำอธิบาย (description) สำหรับ data type code ที่กำหนด
ขั้นตอนการทำงาน
1. นำเข้า NumPy
import numpy as np
2. รายการ data type codes
arr = ['S1', '?', 'B', 'D', 'G', 'F', 'I', 'H', 'L', 'O', 'Q', 'S', 'U', 'V',
'b', 'd', 'g', 'f', 'i', 'h', 'l', 'q']
3. แสดงคำอธิบายแต่ละ code
for i in arr:
print(i, ' : ', np.typename(i))
ตัวอย่างโค้ดเต็ม
import numpy as np
arr = ['S1', '?', 'B', 'D', 'G', 'F', 'I', 'H', 'L', 'O', 'Q', 'S', 'U', 'V',
'b', 'd', 'g', 'f', 'i', 'h', 'l', 'q']
for i in arr:
print(i, ' : ', np.typename(i))
ผลลัพธ์
S1 : character ? : bool B : unsigned char D : complex double precision G : complex long double precision F : complex single precision I : unsigned integer H : unsigned short L : unsigned long integer O : object Q : unsigned long long integer S : string U : unicode V : void b : signed char d : double precision g : long precision f : single precision i : integer h : short l : long integer q : long long integer
ประโยชน์: ใช้ดูความหมายของ dtype character codes ได้อย่างรวดเร็ว