Ogni oggetto numpy.ndarray è accompagnato da un oggetto numpy.dtype (un’istanza della classe numpy.dtype) che fornisce informazioni sui suoi elementi
import numpy as np
x=np.array([1,2,3,4,5])
dt=x.dtype
Attributi
- dt.byteorder
- dt.itemsize
- dt.name
- dt.type
- …
Tipi
| numpy | character code | linguaggio C | valori | |
|---|---|---|---|---|
np.int8 | ‘b‘ | char | -128 127 | |
np.int16 | np.short | ‘h‘ | short | -32 768 32 767 |
np.int32 | np.intc | ‘i‘ | int | -2 147 483 648 2 147 483 647 |
np.int64 | np.int_ | ‘l‘ | long | -9 223 372 036 854 775 808 9 223 372 036 854 775 807 |
np.longlong | ‘q‘ | long long | ||
np.ubyte | ‘B‘ | unsigned char | 0 255 | |
np.uint16 | np.ushort | ‘H‘ | unsigned short | 0 65 535 |
np.uint32 | np.uintc | ‘I‘ | unsigned int | 0 4 294 967 295 |
np.uint64 | np.uint | ‘L‘ | unsigned long | 0 18 446 744 073 709 551 615 |
np.longlong | ‘Q‘ | unsigned long long | ||
np.float16 | np.half | ‘e‘ | ||
np.float32 | np.single | ‘f‘ | float | |
np.float64 | np.double | ‘d‘ | double | |
np.float128 | np.longdouble | ‘g‘ | long double | |
np.complex64 | np.complex_ | ‘F‘ | ||
np.complex128 | np.complex_ | ‘D‘ | ||
np.complex256 | np.longcomplex | ‘G‘ | ||
np.bool8 | np.bool_ | ‘?‘ | ||
| … | … | … |
numpy.dtype(…)
Restituisce un oggetto con le informazioni sul tipo di dato specificato
- dtype(‘int32’)
- dtype(‘int64’)
- …