I have a code that looks like this:
import numpy as np
data =[['2015-07-21 22:18:04', -999.25, -999.25, -999.25, -999.25, -999.25, -999.25, -999.25, -999.25, -999.25, -999.25, -999.25, -999.25, 10.1, -999.25, -999.25],
['2015-07-21 22:18:05', -999.25, -999.25, -999.25, -999.25, -999.25, -999.25, -999.25, -999.25, -999.25, -999.25,
-999.25, -999.25, 10.1, -999.25, -999.25],
['2015-07-21 22:18:06', -999.25, -999.25, -999.25, -999.25, -999.25, -999.25, -999.25, -999.25, -999.25, -999.25,
-999.25, -999.25, 10.1, -999.25, -999.25]]
arr = np.array(data)
depth = arr[:, 1]
print(type(depth))
diff = [depth[i] - depth[i - 1] for i in range(len(depth))][1:]
diff_index = [i for i, item in enumerate(diff) if item > 0]
data = [data[row] for row in diff_index]
When I run my code, I get the following error msg:
diff = [depth[i] - depth[i - 1] for i in range(len(depth))][1:]
TypeError: unsupported operand type(s) for -: 'numpy.str_' and 'numpy.str_'
I've never used numpy before, so I am confused. I couldn't find online documentation that can help me, but its probably because I don't know most of numpy stuff.
I want to select the i-th element from the numpy array, and perform arithmetic operations. How can one fix my code so that it will do the job?