numpy常用功能总结
1.数组重构reshape
In [2]: arr=np.arange(16).reshape(2,8)
out[2]:
In [3]: arr
out[3]:
array([[ 0, 1, 2, 3, 4, 5, 6, 7],
[ 8, 9, 10, 11, 12, 13, 14, 15]])
In [4]: arr.reshape(4,-1) #将arr变成4行的格式,列数自动计算的(c=4, d=16/4=4)
out[4]:
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11],
[12, 13, 14, 15]])
---------------------
作者:我是二师兄
来源:CSDN
原文:https://blog.csdn.net/W_weiying/article/details/82112337
版权声明:本文为博主原创文章,转载请附上博文链接!
2.取最值
count2 = np.array(count1).reshape(len(count1),1)
count_max = count2.max()
count_min = count2.min()
3.np.stack与np.column_stack
可理解为合并(或者堆叠),其中np.column_stack大概是按列进行合并,有点复杂,详情百度
predicted_value = pd.DataFrame(predicted_value)
real_value = pd.DataFrame(real_value)
result_xlsx=np.column_stack((real_value,predicted_value))
df=pd.DataFrame(result_xlsx,columns=['real_value','predicted_value'])
df.to_excel('test_result.xlsx')