1、对单数据类型重复:
np.repeat(3,2)
#array([3, 3])
np.repeat('abd',2)
#array(['abd', 'abd'], dtype='<U3')
2、对多维数据重复
#未指定维度
np.repeat([[1],[2],[3]],2)
#array([1, 1, 2, 2, 3, 3])
np.repeat([[1],[2],[3]],2)
np.repeat(["abd","def"],2)
#array(['abd', 'abd', 'def', 'def'], dtype='<U3')
#指定维度
#列重复
np.repeat([[1,2],[3,4]],2,axis=1)
array([[1, 1, 2, 2],
[3, 3, 4, 4]])
#行重复
np.repeat([[1,2],[3,4]],2,axis=0)
array([[1, 2],
[1, 2],
[3, 4],
[3, 4]])