Python numpy中np_r和np_c Posted on 2018-09-10 | In python | np.r_是按行连接两个矩阵,就是把两矩阵上下相加,要求行数相等,类似于pandas中的concat() np.c_是按列连接两个矩阵,就是把两矩阵左右相加,要求列数相等,类似于pandas中的merge() 123456789101112131415161718192021222324import numpy as np def test(): ''' numpy函数np.c_和np.r_学习使用 ''' data_list1=[4,6,12,6,0,3,7] data_list2=[1,5,2,65,6,7,3] data_list3=[1,5,2,65,6,6,8] print u'np.r_ data_list1和data_list2合并' print np.r_[data_list1,data_list2] print u'np.r_ data_list1和data_list3合并' print np.r_[data_list1,data_list3] print u'np.c_ data_list1和data_list2合并' print np.c_[data_list1,data_list2] print u'np.c_ data_list1和data_list3合并' print np.c_[data_list1,data_list3] if __name__=='__main__': test()