Python for MATLAB Users
Justin Kiggins
Product Manager
my_list = [8, 6, 7, 5, 3, 0 ,9]
print(my_list[2])
7
print(my_list[-3:])
[3, 0, 9]
my_list = [8, 6, 7, 5, 3, 0 ,9]
import numpy as np
my_array = np.array(my_list)
type(my_array)
numpy.ndarray
list_of_lists = [[2, 3], [9, 0], [1, 4]]
import numpy as np arr = np.array(list_of_lists) print(arr)
[[2, 3]
[9, 0]
[1, 4]]
arr.shape
(3, 2)
NumPy Arrays | Lists |
---|---|
All elements must be same type | Can mix types |
(+) does element-wise addition |
(+) concatenates lists |
Multidimensional | Single dimension |
Range & Boolean indexing | Only Range indexing |
Need to do math?
Storing complex structures?
Multidimensional data?
Python for MATLAB Users