0.511474 0.488526
0.468783 0.531217
0.35111 0.64889
0.594834 0.405166
“如何从python中的每一行中找到最大值,并将其存储在numpy数组或pandas Dataframe中,并将其存储在numpy数组中,即下面的输出”
0.511474
0.531217
0.64889
0.594834
答案 0 :(得分:2)
使用numpy amax
函数。 np.amax
import numpy as np
a = np.array([[0.511474, 0.488526],
[0.468783, 0.531217],
[0.35111, 0.64889],
[0.594834, 0.405166]])
x = np.amax(a, 1)
print(x)
返回:
[0.511474 0.531217 0.64889 0.594834]