i'm having trouble with 3.4 using numpy. My question is to know how can i have a numpy matrix with plain string format instead byte-string.
def res(data):
M = np.zeros(data.shape).astype(dtype='|S20')
lines,columns = M.shape
for l in range(lines):
M[l][0] = data[l][1]
M[l][1] = data[l][2]
M[l][2] = data[l][3]
return M
**result python2.7**
[['Ann' '38.72' '-9.133']
['John' '55.68' '12.566']
['Richard' '52.52' '13.411']
['Alex' '40.42' '-3.703']]
**result python3.4**
[[b'Ann' b'38.72' b'-9.133']
[b'John' b'55.68' b'12.566']
[b'Richard' b'52.52' b'13.411']
[b'Alex' b'40.42' b'-3.703']]
In Python3.4 How can i have my Matrix in plain string like in example for python2.7 this is bad because i have functions that expect string values and not byte-strings.
Any help would be great. thanks
M[l,0]. As to your problem, the base string type in 3.4 is unicode, while in 2.7 it's ascii. So for some purposesb'abc'is the 3.4 equivalent, but for other just typestr.