Skip to the content.

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:

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.


Numpy Tutorial

Numpy is a commonly used Python data analysis package.

With NumPy, we work with multidimensional arrays.

Creating a NumPy Array

  1. import the numpy package
  2. 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)
wines.shape

Output:
(1599, 12)

Alternate NumPy Array Creation Methods

  1. 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

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.

<—BACK