Why am I getting this error in the following code? I'm using Spyder 3.1.4, and I am running this through IPython console.
list_stock = []
for key,value in data_dict.iteritems():
list_stock.append(value["salary"])
sorted_list_stock = sorted(list_stock)
scaler = MinMaxScaler()
weights = np.array(sorted_list_stock)
print weights
rescaled_weights = scaler.fit_transform(float(weights))
print rescaled_weights
edit: full error:
['477' '6615' '63744' ..., 'NaN' 'NaN' 'NaN'] Traceback (most recent call last):
File "", line 1, in runfile('C:/Users/ptillotson/Documents/Python Scripts/ud120-projects-master/k_means/k_means_cluster.py', wdir='C:/Users/ptillotson/Documents/Python Scripts/ud120-projects-master/k_means')
File "C:\ProgramData\Anaconda2\lib\site-packages\spyder\utils\site\sitecustomize.py", line 880, in runfile execfile(filename, namespace)
File "C:\ProgramData\Anaconda2\lib\site-packages\spyder\utils\site\sitecustomize.py", line 87, in execfile exec(compile(scripttext, filename, 'exec'), glob, loc)
File "C:/Users/ptillotson/Documents/Python Scripts/ud120-projects-master/k_means/k_means_cluster.py", line 89, in rescaled_weights = scaler.fit_transform(float(weights))
TypeError: only length-1 arrays can be converted to Python scalars
float(weights)
. – Moses Koledoye