reading-notes

Data Analysis

What is Jupyter Lab

While in command mode (press Esc to activate):

While in edit mode (pressEnter to activate)

Numpy

Importing/exporting

np.loadtxt('file.txt') | From a text file np.genfromtxt('file.csv',delimiter=',') | From a CSV file np.savetxt('file.txt',arr,delimiter=' ') | Writes to a text file np.savetxt('file.csv',arr,delimiter=',') | Writes to a CSV file

Creating Arrays np.array([1,2,3]) | One dimensional array np.array([(1,2,3),(4,5,6)]) | Two dimensional array np.zeros(3) | 1D array of length 3 all values 0 np.ones((3,4)) | 3x4 array with all values 1 np.eye(5) | 5x5 array of 0 with 1 on diagonal (Identity matrix) np.linspace(0,100,6) | Array of 6 evenly divided values from 0 to 100 np.arange(0,10,3) | Array of values from 0 to less than 10 with step 3 (eg [0,3,6,9]) np.full((2,3),8) | 2x3 array with all values 8 np.random.rand(4,5) | 4x5 array of random floats between 0–1 np.random.rand(6,7)*100 | 6x7 array of random floats between 0–100 np.random.randint(5,size=(2,3)) | 2x3 array with random ints between 0–4

References