In this module, we use jupyter notebooks to write the code, store results (as text or images), document both code and results, and to run data mining applications.
When all the required dependencies have been met, you can start the Jupyter web server from the command line and point your browser at the relevant url. Your browser then becomes the client that allows you to interact with the server.
We will go into how notebooks can be used in a later lab.
For now, we will just check that the software has been installed successfully.
If you have not done so already, you need to download auto-mpg.csv.
For this purpose, my advice is to change directory to where you downloaded auto-mpg.csv
1 | |
Alternatively, if on MS Windows, just start Anaconda Prompt and work from there.
1 2 3 4 5 | |
Note that jupyter-lab will generally open a browser tab for you. In your browser you should see the jupyter-lab interface.
The jupyter-lab page provides a handy "button" for this. Pressing that creates a new notebook with a default name of Untitled.ipynb. If you have an existing notebook, you can use the navigation panel to the Left to find the file and can open it by clicking on it.
At this stage you might as well File > Save As a more memorable name.
We are going to read the auto-mpg.csv file into a pandas dataframe and quickly view its contents.
Assuming the auto-mpg.csv file has been placed in the same folder as the notebook, in the first cell (which should be of type code, not markdown or raw), type
1 2 3 | |
Click the "play" button directly above the code cell and the notebook uses the Python 3 kernel to run your script.
The output cell below your code cell will contain the first 5 rows of the auto_mpg data frame.
Code to Markdown and some comments/documentation in markdown format.auto_mpg['weight'].max()to see how to select particular columns and to apply certain functions to sets of values (car weights in pounds, in this instance).Enjoy!
Ctrl-C then y.