For loops are great, but there are times when for loops are too slow. In these situations, it is better to use vectorized functions, which are faster and more concise. In this video, learn how to use vectorized functions from the NumPy, SciPy, and pandas libraries instead of writing for loops.
- [Instructor] For loops are powerful structures … but there are times when for loops are too verbose … or slow and can be avoided. … At those times, it's better to use vectorized functions … which can perform the same tasks … but in a more concise or efficient manner. … The NumPy, SciPy and Pandas libraries, … have several vectorized functions that are available to use. … In this video, I will be providing examples of scenarios … in which vectorized functions achieve the same goal … as for loops in fewer lines of code. … Let's say that I have a data set containing information … about students' grades across five exams. … In the first example, … I want it to compute the standard deviation … for the student's grades across all exams. … Note that the standard deviation for a set of data … is a measure of how spread out the values are. … And I computed the standard deviation using a for loop here. … First, I computed the mean for students grades … across all exams and save that in a variable named mean. …
Skill Level Intermediate
1. Avoid Mistakes in Coding Practices
2. Avoid Mistakes in Structuring Code
3. Avoid Mistakes in Handling Data
4. Avoid Mistakes in Machine Learning
Using redundant features1m 45s
Get started with Python1m 7s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
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.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.