Abhay Singh
Abhay Singh

Reputation: 437

How to convert list to numpy array?

While converting the list to numpy array gives the error

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

Code:

d=np.array(list1)

Upvotes: 1

Views: 2149

Answers (1)

A DUBEY
A DUBEY

Reputation: 846

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)

Upvotes: 4

Related Questions