range returns a list. You could use
range([start,] stop[, step]) -> list of integers
Return a list containing an arithmetic progression of integers.
xrange([start,] stop[, step]) -> xrange object
range(), but instead of returning a list, returns an object that
generates the numbers in the range on demand. For looping, this is
slightly faster than
range() and more memory efficient.
The other thing that strikes me is the slice in the argument to
np.mean. The slice is always of length 3. Assuming this is an arithmetic mean, you could turn the division into
(3.0 * data[i] / (data[i - 2] + data[i - 1] + data[i]))
So putting it together
return [(3.0 * data[i] / (data[i - 2] + data[i - 1] + data[i])) - 1
for i in xrange(len(data) - 1, len(data) - 362, -1)]
and you could further optimize the sum of last three values by recognizing that if
x = a[n] + a[n+1] + a[n+2]
and you have already computed
y = a[n - 1] + a[n] + a[n + 1]
x = y + (a[n - 1] - a[n + 2])
which helps whenever a local variable access and assignment is faster than accessing an element in a series.