Reputation: 11
from numpy import *
arr = ([1,2,3,4,5])
print(arr.dtype)
I have written this program but when I am trying to use dtype
I'm getting this below error, please suggest why this is happening and how can I check the type:
print(arr.dtype)
AttributeError: 'list' object has no attribute 'dtype'
Upvotes: 0
Views: 662
Reputation: 54168
You did not create a numpy array, just a classic python list
from numpy import array
arr = array([1, 2, 3, 4, 5])
print(arr.dtype) # int32
Also avoid importing *
, prefer the explicit imports
Upvotes: 2