It takes a dict as the second argument not an array:
From the docs:
mdict : dict
Dictionary from which to save matfile variables.
I am not overly familiar but I imagine you pass the name as the key and the array as the value, something like:
sio.savemat('final.mat',{"foo":temp})
Answer from Padraic Cunningham on Stack OverflowIt takes a dict as the second argument not an array:
From the docs:
mdict : dict
Dictionary from which to save matfile variables.
I am not overly familiar but I imagine you pass the name as the key and the array as the value, something like:
sio.savemat('final.mat',{"foo":temp})
I solved this issue as follow:
from scipy.io import savemat
import numpy as np
num= np.arange(20)
mymat={'num':num}
savemat('mymat.mat', mymat)
AttributeError: 'numpy.ndarray' object has no attribute 'numpy'
Error creating numpy v-stack, 'AttributeError: 'numpy.ndarray' object has no attribute 'np'
AttributeError: 'numpy.ndarray' object has no attribute 'items'. Did you mean: 'item'?
AttributeError: 'numpy.ndarray' object has no attribute 'dim'
Videos
Hi,
I'm trying to create a numpy v-stack and creating 3 np.array's for it, by filling them with a loop:
I get the error: 'AttributeError: 'numpy.ndarray' object has no attribute 'np' . I think I'm using the wrong notation to append to the empty arrays:
neighbor_id = [id_ for id_ in range(1, n_obs) if id_ != user_id]
neighbor_id_arr = np.array(neighbor_id)
similarity = np.array([])
num_interactions = np.array([])
# get similarity and num_interactions
for id_ in neighbor_id:
similarity.np.append(np.dot(user_item.loc[user_id],user_item.loc[id_])) #The issue is here, I think
num_interactions.np.append(user_interactions.loc[id_])
c = numpy.vstack((neighbor_id_arr, similarity,num_interactions))
Thanks!
James