From the course: More Python Tips, Tricks, and Techniques for Data Science

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Code profiling and timing

Code profiling and timing - Python Tutorial

From the course: More Python Tips, Tricks, and Techniques for Data Science

Start my 1-month free trial

Code profiling and timing

- [Instructor] Once you have your code working, it's always a good practice to dig into its efficiency. To do that, you should check for the execution time of your operations and determine where the bottleneck is. And when we talk about efficiency, timing and code profiling are the two best practices that every data scientist should know how to do. In this video, I will walk you through the array of functionalities that IPython offers to profile and time your code. So first off we have the percentage time magic command which is used to time the execution of single statement of code. So, let's say I want to time the file reading operation by pandas, all I need to do is first import pandas as PD. And then I want to time the reading operation. So, first I will type my magic command which is %time and then the command to read the file. So pd.read_csv function and pass the bot to the file. So I have in my data directory…

Contents