Numpy.dot TypeError: Cannot cast array data from dtype('float64') to dtype('S32') according to the rule 'safe'
By : ibrahima gueye
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Just taking the input from BrenBarn and Warren Weckesser to provide a code snippet which should run (by converting your strings to float): code :
a = map(lambda x: float(x),a)
b = map(lambda x: float(x),b)
np.dot(a,b.T)
a = map(float,a)
b = map(float,b)
np.dot(a,b.T)

Cannot cast array data from dtype('float64') to dtype('int32') according to the rule 'safe'
By : user1595877
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Explanation of Error: This is illustrative of an interesting property of numpy arrays: all elements of a numpy array must be of the same type code :
>>> array1 = np.array([[23, 632, 634],[23.5, 67, 123.6]])
>>> array1
array([[ 23. , 632. , 634. ],
[ 23.5, 67. , 123.6]])
>>> type(array1[0][0])
<class 'numpy.float64'>
>>> array2 = np.array([[23, 632, 'foo'],[23.5, 67, 123.6]])
>>> type(array2[0][0])
<class 'numpy.str_'>

Cannot cast array data from dtype('O') to dtype('float64') according to the rule 'safe'
By : ManuelSou
Date : March 29 2020, 07:55 AM
around this issue When running my Tukey test, it gives me this error: , Try replacing the line code :
mc = MultiComparison(df['Score'], df['Group'])
mc = MultiComparison(df['Score'].astype('float'), df['Group'])
mc = MultiComparison(pd.to_numeric(df['Score'], errors='coerce'), df['Group'])

Cannot cast array data from dtype('float64') to dtype('int64') according to the rule 'safe' ! astype function between in
By : rahul
Date : March 29 2020, 07:55 AM
This might help you np.choose expects an int array as first argument, but you seem to be passing floats. You can cast the first argument to mitigate this: code :
y = np.choose(y.astype(int), [0,2,1]).astype(float)

Matplotlib Error TypeError: Cannot cast array data from dtype('float64') to dtype('<U32') according to the rule 'safe
By : user2471315
Date : March 29 2020, 07:55 AM
like below fixes the issue The error is because you are trying to plot three lists of str type objects. They need to be of float or similar type, and cannot be implicitly casted. You can do the type casting explicitly by making the modification below: code :
for column in readCSV:
xs = float(column[1])
ys = float(column[2])
zs = float(column[3])
for column in readCSV:
xs = float(column[1])
ys = float(column[2])
zs = float(column[3])
XS.append(xs)
YS.append(ys)
ZS.append(zs)
ax.scatter(XS, YS, ZS, c='r', marker='o')
ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')

