[:,np.newaxis],与(3L,1L)和(3L,)

来源:互联网 发布:fanuc数控系统图纸编程 编辑:程序博客网 时间:2024/05/16 10:07
#coding=utf-8import numpy as npx = np.array([[1],[2],[3],[4],[5]])y = np.array([4,5,6,7,8])print x.shapeprint y.shapey[1:3][:,np.newaxis]=x[1:3]print y

输出结果为:

(5L, 1L)(5L,)[4 2 3 7 8]

[:,np.newaxis],起到了增加一个维度的作用!


原创粉丝点击