Kagula
Feb-27-2023
Introduction
JupyterLab is an extensible environment for interactive and reproducible computing, based on the Jupyter Notebook and Architecture, it's convenient for python engaging with data science and machine learning because it's already brought with Numpy, Pandas, MatPlotLib and Scikit-learn libraries, etc.
Environment
- Microsoft Windows [Version 10.0.19044.2604]
- Anaconda-3.2-2022.10
- python3.9
Content
Installation
Before installing Anaconda, remove installed Python from the control panel to avoid different Python versions occur conflicts.
Download the Anaconda3 packet from 'https://www.anaconda.com/' and startup it. choice 'All User' Option to avoid space characters in the install path. The default install path will be 'C:\ProgramData\Anaconda3'. After setup, launch it with Anaconda Navigator and click JupyterLab, after a while, you can see the program is open in Internet Explorer.
The Cell
pic1 Hello world
The edit region is called 'Cell', we can have many cells. We can run the current cell by pressing 'Ctrl+Enter'. the blue vertical line on the left of the Cell is indicated in command mode.
If everything is ok, we will see the output below the snippet of python you just have written.
In the command mode, you can delete the current cell by using the shortcut 'd,d'.
To Access External Files
Step1, create a new snippet for demo:
Create a new cell and write the snippet like below and save it as 'HelloWorld.ipynb'. 'ipynb' is a file format that is used by Anaconda.
import pandas as pd
df = pd.read_csv('vgsales.csv') #return a data frame object
df
Step2, download the file which the demo needs:
Download vgsales.csv from www.kaggle.com/gregorut/videogamesales, and put it in the directory where 'HelloWorld.ipynb' stays.
Last Step, Run it:
Press the shortcut 'Ctrl+Enter' to run the snippet of python. if everything is ok you will see the table below the cell.
pic2. the table gets from a CSV file.
Complement
If the left vertical line of the cell is green, it indicated the cell is in edit mode, you can use the Esc key to switch to command mode.
Below are some commonly used shortcuts.
- key 'a' inserts the cell above the current cell.
- key 'b' inserts the cell below the current cell.
- key 'Tab' lists the methods of the object.
- 'Shift+Tab' lists the parameters of the function where your cursor is.
- 'Ctrl+/' switches on/off comment before the current line.
- 'Shift+enter' run the current cell and forward.
Reference
- www.anaconda.com