Calculate speed from distance and time. Learn how to use Pandas shift, sum and other methods. learn how to convert Pandas time delta objects to scalars. You can also resample the DataFrame to different time granularity.
- [Instructor] We now have a function…that can calculate distances…and we also have time information.…That's all the information we need to calculate speed.…Let's ask why calculating…the distances between all the points.…In regular Python, we'll use a follow.…But in Pandas, and in scientific Python in general,…we try not to use follow ups…since they are slower than using Vector operations.…Since we're using NumPy U functions circle_dist…it means we can use it on hall erase.…However, we need pairs of points.…
And for that we're going to use the shift method.…Let's see an example.…So S a pd.series of np.arange of five.…Then if you look at S,…it's from zero to four.…Now let's try.…s.shift…Everything is shifted down.…We can also shift up.…s.shift minus one…and now everything is shifted up.…How does shift help us?…Dist equal circle dist of df.latitude…and df.longitude…and then df.latitude again,…this time shifted.…
And again .shift.…And let's see the first 10 values.…We see that the first value is nan,…not a number.…Since we have nan at the start of latitude and longitude.…
- Working with Jupyter notebooks
- Using code cells
- Extensions to the Python language
- Markdown cells
- Editing notebooks
- NumPy basics
- Broadcasting, array operations, and ufuncs
- Folium and Geo
- Machine learning with scikit-learn
- Plotting with matplotlib and bokeh
- Branching into Numba, Cython, deep learning, and NLP
Skill Level Intermediate
1. Scientific Python Overview
2. The Jupyter Notebook
3. NumPy Basics
Manage environments5m 11s
6. Folium and Geo
7. NY Taxi Data
10. Other Packages
11. Development Process
Next steps1m 33s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.