Code 401 Class 11 Reading Notes
What is Jupyter Lab
JupyterLab is a next-generation web-base user interface for Project Jupyter.
JupyterLab enables you to work with documents and activities such as:
- Jupyter notebooks
- text editors
- terminals
As well as custom components in a flexible, integrated, and extensible manner.
You can array multiple documents and activities side by side in the work area using tabs and splitters.
- Code Consoles provide transient scratchpads for running code interactively, with full support for rich output. A code console can be linked to a notebook kernel as a computation log from the notebook, for example.
- Kernal-backed documents enable code in any text file (Markdown, Python, R, LaTeX, etc.) to be run interactively in any Jupyter kernel.
- Notebook cell outputs can be mirrored into their own tab, side by side with the notebook, enabling simple dashboards with interactive controls backed by a kernel.
- Multiple views of documents with different editors or viewers enable live editing of documents reflected in other viewers. For example, it is easy to have live preview of Markdown, Delimiter-separated Values, or Vega/Vega-Lite documents.
Numpy Tutorial
Numpy is a commonly used Python data analysis package.
With NumPy, we work with multidimensional arrays.
- NumPy array, the number of dimensions is called the rang, and each dimension is called an axis So the rows are the first axis, and the columns are the second axis.
Creating a NumPy Array
- import the
numpy
package - Pass the lists of lists
things
into the array function, which converts it into a NumPy array.- Exclude the header row with list slicing.
- Specify the keyword argument
dtype
to make sure each element is converted to a float.
import csv
with open("winequality-red.csv", 'r') as f:
wines = list(csv.reader(f, delimiter=";"))
import numpy as np
wines = np.array(wines[1:], dtype=np.float)
- Check shape of number of rows and colmns in our data using the
shape
property of NumPy arrays:
wines.shape
Output:
(1599, 12)
Alternate NumPy Array Creation Methods
- import numpy as np
empty_array = np.zeros((3,4))
empty_array
Or create an array where each element is a random number. A good way to quickly test code with sample arrays.
np.random.rand(3,4)
NumPy To Read in Files
- Use genfromtxt function to read the .csv file
- Specify the keyword argument
delimiter=";"
so that the fields are pasted properly. - Specify the keyword argument
skip_header=1
so that the header row is skipped.
wines = np.genfromtxt("winequality-red.csv", delimiter=";", skip_header=1)
Indexing NumPy Arrays
To access element at row 3 and column 4
wines[2,3]
Things I want to know more about
Working with Jyputer.