import numpy as np
a = np.array([[1, 2, 3], [4, 5, 6]])
mean_along_rows = np.mean(a, axis=0)
print(mean_along_rows)
mean_along_columns = np.mean(a, axis=1)
print(mean_along_columns)
numpy.max() ;
numpy.min()
numpy.argmax() #沿軸max的index
numpy.argmin() #沿軸min的index
axis參數同numpy.mean()
推薦hahow線上學習python: https://igrape.net/30afN
import numpy as np
a = np.array([[1, 2, 3], [4, 5, 6]])
max_along_rows = np.max(a, axis=0)
print(“max_along_rows:”, max_along_rows)
max_along_columns = np.max(a, axis=1)
print(“max_along_columns:”, max_along_columns)
argmax_along_rows = np.argmax(a, axis=0)
print(“argmax_along_rows:”, argmax_along_rows)
argmax_along_columns = np.argmax(a, axis=1)
print(“argmax_along_columns:”, argmax_along_columns)
推薦hahow線上學習python: https://igrape.net/30afN
近期留言