np arry to list
import numpy as np
List = arry.tolist()
|
Create a list
print(np.linspace(0, 100, 51))
|
[ 0. 2. 4. 6. 8. 10. 12. 14. 16. 18. 20. 22. 24. 26.
28. 30. 32. 34. 36. 38. 40. 42. 44. 46. 48. 50. 52. 54.
56. 58. 60. 62. 64. 66. 68. 70. 72. 74. 76. 78. 80. 82.
84. 86. 88. 90. 92. 94. 96. 98. 100.]
np.sum(array1-array2) np.mean()
|
append
np.append(np1, np2,axis=0)
|
Reduce Dimension
x = np.array([[1, 2],[3, 4]]) print(np.ravel(x)) print(np.ravel(x,'F'))
|
Locating (argwhere)
arr = np.random.randint(0,10, (3,4)) index = np.argwhere(arr < 5) index2 = np.where(arr < 5)
arr.argmax() arr.argmin()
|
Axis
Axis flip / swap
frame2 = frame.swapaxes(0,1)
frame.shape frame2.shape
|
(360, 480, 3)
(480, 360, 3)
Replace
ummmm... I am not really like to using numpy because I thing data.frame() in R is much better.