[Numpy-discussion] inplace operations

BBands bbands at gmail.com
Fri Jan 26 17:09:55 CST 2007


If I have a NumPy array like so:

[[1, 12],
 [2, 13],
 [3, 14],
 [4, 15],
 [5, 16],
 [6, 15],
 [7, 14]]

How can I do an inplace diff, ending up with this?

[[1, 0],
 [2, 1],
 [3, 1],
 [4, 1],
 [5, 1],
 [6, -1],
 [7, -1]]

Also, can I covert to natural logs in place?

[[1, 2.4849],
 [2, 2.5649],
 [3, 2.6391],
 [4, 2.7081],
 [5, 2.7726],
 [6, 2.7081],
 [7, 2.5649]]

Thanks in advance,

     jab
-- 
John Bollinger, CFA, CMT
www.BollingerBands.com

If you advance far enough, you arrive at the beginning.


More information about the Numpy-discussion mailing list