here my code:
ldata = []
for line in f:
tmp = line.strip().split(',')
ldata.append([float(i) for i in tmp[2:]])
print len(ldata),len(ldata[0])
cc = np.array(ldata)
print cc.shape
d = cc*0.25
The result:
4345,560
(4345,)
Traceback (most recent call last):
File "C:\Users\Che\workspace\recali.py", line 62, in <module>
d = cc*0.25
TypeError: can't multiply sequence by non-int of type 'float'
The shape of the array should (4345,560), while it shows (4345,)....and can not multiply a float. Why did this happen?
d = cc*0.25to do?d = [x * 0.25 for x in cc]numpy.array()to make you a 2d array from a list of lists, they have to be all the same length.