numpy常用创建

Array creation routines

numpy.empty

Return a new array of given shape and type, without initializing
entries.
numpy.empty
Return a new array with the same shape and type as a given array.
numpy.empty_like

numpy.empty(shape, dtype=float, order=‘C’, *, like=None)

a = np.empty((2, 2, 2))

numpy常用创建_第1张图片

numpy.zeros

Return a new array of given shape and type, filled with zeros.
numpy.zeros
Return an array of zeros with the same shape and type as a given array.
numpy.zeros_like

numpy.zeros(shape, dtype=float, order=‘C’, *, like=None)

a = np.zeros((2, 2))

在这里插入图片描述

numpy.ones

Return a new array of given shape and type, filled with ones.
numpy.ones
Return an array of ones with the same shape and type as a given array.
numpy.ones_like

numpy.ones(shape, dtype=None, order=‘C’, *, like=None)

a = np.ones((2, 2, 2))

numpy常用创建_第2张图片

numpy.array

Create an array.
numpy.array

numpy.array(object, dtype=None, *, copy=True, order=‘K’, subok=False, ndmin=0, like=None)

b = [[1, 2, 3], [4, 5, 6]]
a = np.array(b)

在这里插入图片描述

你可能感兴趣的:(numpy,numpy,python,数据分析)