clus = np.asarray(clus)
cens[0] = np.mean(clus, axis=0, dtype=np.float32)
#
clus1, clus2, clus3 are 2D arrays of coordinates. I think it can calculate the mean of x-axis and y-axis separately by calling numpy.mean and set axis to 0, then it returns me [x,y]. ( https://docs.scipy.org/doc/numpy/reference/generated/numpy.mean.html )
but I failed and got the error below.
[TypeError: cannot preform reduce with flexible type][1]
How can I fix it? Or what does the error mean?
thanks
#update 2017.9.9
clus1,2,3 are lists read from csv file like this
98,157 101,130 206,218 158,162 189,237 212,186 63,35 196,188 185,176
and read like this
with open('clus_1.csv', 'rb') as c1: rc1 = csv.reader(c1) list_c1 = list(rc1) clus.append(list_c1)
What I read from csv files are not ints but strings. add codes below can solve it
clus = clus.astype(np.float32)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.