欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

第六篇:python中numpy.zeros(np.zeros)的使用方法

程序员文章站 2022-05-25 20:08:39
用法:zeros(shape, dtype=float, order='C') 返回:返回来一个给定形状和类型的用0填充的数组; 参数:shape:形状 dtype:数据类型,可选参数,默认numpy.float64 dtype类型: t ,位域,如t4代表4位 b,布尔值,true or fals ......

用法:zeros(shape, dtype=float, order='c')

返回:返回来一个给定形状和类型的用0填充的数组;

参数:shape:形状

dtype:数据类型,可选参数,默认numpy.float64

dtype类型:

t ,位域,如t4代表4位

b,布尔值,true or false

i,整数,如i8(64位)

u,无符号整数,u8(64位)

f,浮点数,f8(64位)

c,浮点负数,

o,对象,

s,a,字符串,s24

u,unicode,u24

order:可选参数,c代表与c语言类似,行优先;f代表列优先

示例:生成4行10列的数组

import numpy as np
files = [1,3,4,5]
features_matrix = np.zeros((len(files), 10))
print(features_matrix)

参考:https://blog.csdn.net/qq_36621927/article/details/79763585