I believe that this is simple question, but I’m new to Python so any suggestion will be appreciated.
I have matrix of strings, and I need to convert every element into float type and then to increase it for some number. I did that like this:
for i in range(0,len(matrix)):
for j in range(0,len(matrix[i])):
for k in range(0,len(matrix[j])):
matrix[i][j][k] = float(matrix[i][j][k]) + 5.555
Is there any other way of doing this in order to increase speed? Performance is really low when I have matrix[50][50][50] or bigger.
Is there one-line method that could increase all elements at once?
Whenever you’re doing array work in Python, it’s best to use the numpy library if possible.