I am very new to Pandas, but familiar with Numpy and Python.
Suppose I have a `Pandas.DataFrame 'of X, Y points (float64) indexed by time (datetime), how can I pythonically calculate the speeds from this, providing that I already know how to calculate Euclidean distances between points?
EDIT: I just read the help of pandas.Series.diff() , but still I would like to βreplaceβ the subtraction used for diff with another function, for example `euclidean_distance (). Is there any way to do this?
The DataFrame looks like (index in the first column, position in the second):
2009-08-07 16:16:44 [37.800185, -122.426361] 2009-08-07 16:16:48 [37.800214, -122.426153] 2009-08-07 16:16:49 [37.800222, -122.426118] 2009-08-07 16:16:52 [37.800197, -122.426072] 2009-08-07 16:17:32 [37.800214, -122.425903] 2009-08-07 16:17:34 [37.800236, -122.425826] 2009-08-07 16:17:40 [37.800282, -122.425534] 2009-08-07 16:17:44 [37.800307, -122.425315] 2009-08-07 16:17:46 [37.800324, -122.425207] 2009-08-07 16:17:47 [37.800331, -122.425153] 2009-08-07 16:17:49 [37.800343, -122.425047] 2009-08-07 16:17:50 [37.800355, -122.424994] 2009-08-07 16:17:51 [37.800362, -122.424942] 2009-08-07 16:17:54 [37.800378, -122.424796] 2009-08-07 16:17:56 [37.800357, -122.424764]
I want some way to get the speed from this, since the speed of the first data sample will always be zero by definition (the timedelta from the previous sample is not known).
Thanks a lot!
source share