Reputation: 199
I have created a matrix with 100 columns from a text file by counting the value ":READ" out of 100 entries. ie: vector[0][0] = number of :READ in first 100 entries in the file, vector[0][1]= number of :READin next 100 entries in the file and so on using the following code
`
for i in range(start,len(df1),100):
df2=df1.iloc[start:end,]
count=df2.str.count(":READ").sum()
vector[p].append(count)
filewriter.writerow([start, count])
start=end
end=end+100
if(q<window):
q=q+1
else:
q=0
p=p+1
vector.append([])
and when I use it to calculate eigen values,
e_vals, e_vecs = LA.eig(vector)
It gave the following error
ValueError: object arrays are not supported
what could be done? i am not good in python coding.
Upvotes: 4
Views: 17226
Reputation: 355
Try checking the type of the elements, with a simple
print(type(vector[0][0]))
I was having the same error, and in my case, all my elements were:
<class 'sympy.core.numbers.Float'>
After converting every element to float with:
for i in range(len(vector)):
for j in range(len(vector[i]):
vector[i][j] = float(vector[i][j])
I got the results I wanted.
Upvotes: 1