From the course: Testing Python Data Science Code

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Using nbconvert

Using nbconvert

- [Instructor] Jupyter notebooks come with an NB convert utility, which converts notebooks to other formats. One of the things it can do while converting is to run or execute the notebook. Let's use it in our testing. Assume that we have some jogging information and we'd like to find out the mean speed, so here is our information. It is in a csv format with time, latitude, longitude, and height. I'm going to load track that ipynb in visual studio code. You can open it from Jupyter lab or Jupyter notebooks on the browsers as well. And I did some changes to facilitate testing. One thing is I'm getting the name of the CSV file to load from an environment variable called csv file. Then I'm running the notebook as usual, but finally, I'm also adding another cell, which says, if I have a name of the output file, I'm going to generate a json file with a calculated mean speed. And now I can use it in my code, so, let's have a…

Contents