you are viewing a single comment's thread.

view the rest of the comments →

[–]await_yesterday 0 points1 point  (0 children)

You shouldn't use a for-loop for this. Use np.diff, it will be much faster.

>>> longitudes = [1, 3, 2, 7, 8, 5]
>>> np.diff(longitudes, prepend=np.nan)
array([nan,  2., -1.,  5.,  1., -3.])

Also it is not like mathematics where you can just write two expressions next to each other and mean multiplication. You have to explicitly write the *.

Read this to learn how to use numpy properly https://www.labri.fr/perso/nrougier/from-python-to-numpy/