1

While converting the list to numpy array gives the error

AttributeError: 'numpy.int64' object has no attribute 'array"

Code:

d=np.array(list1)
4
  • 4
    Has np been assigned a value elsewhere in the code? Commented Nov 18, 2020 at 7:25
  • 2
    Double check your code somewhere you have reassigned a value to np . Or try import numpy then use numpy .array Commented Nov 18, 2020 at 7:25
  • 1
    what's in list1? is np re-assigned? Commented Nov 18, 2020 at 7:26
  • Thank, it was mentioned somewhere else, silly one Commented Nov 18, 2020 at 7:44

1 Answer 1

4

As mentioned by @venky, check if you are using "np" as a variable somewhere. If not try the code below and see if you get an error. It should work

import numpy as np
mylist = [1,2,3]
a = np.array(mylist)
type(a)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.