python numpy np.full(shape, fill_value, dtype=None, order='C')函数 以指定数值填充指定形状的数组

def full(shape, fill_value, dtype=None, order='C'):
    """
    Return a new array of given shape and type, filled with `fill_value`.
    返回具有给定形状和类型的新数组,并填充“ fill_value”。

    Parameters
    ----------
    shape : int or sequence of ints
        Shape of the new array, e.g., ``(2, 3)`` or ``2``.

	形状:整数或整数序列
         新数组的形状,例如``(2,3)``或``2''。

    fill_value : scalar
        Fill value.
    dtype : data-type, optional
        The desired data-type for the array  The default, `None`, means
         `np.array(fill_value).dtype`.
    order : {'C', 'F'}, optional
        Whether to store multidimensional data in C- or Fortran-contiguous
        (row- or column-wise) order in memory.

	fill_value:标量(就是纯数值变量)
         填充值。
     dtype:数据类型,可选
         数组所需的数据类型默认值为“ None”,表示
          `np.array(fill_value).dtype`。
     顺序:{'C','F'},可选
         是否以C-或Fortran连续存储多维数据
         (按行或按列)顺序在内存中。

    Returns
    -------
    out : ndarray
        Array of `fill_value` with the given shape, dtype, and order.
        具有给定形状,dtype和顺序的“ fill_value”数组。

    See Also
    --------
    full_like : Return a new array with shape of input filled with value.
    empty : Return a new uninitialized array.
    ones : Return a new array setting values to one.
    zeros : Return a new array setting values to zero.
	
	full_like:返回一个新数组,其输入形状填充有值。
     空:返回一个新的未初始化的数组。
     一:将新的数组设置值返回为一。
     零:将新的数组设置值返回零。

    Examples
    --------
    >>> np.full((2, 2), np.inf)
    array([[ inf,  inf],
           [ inf,  inf]])
    >>> np.full((2, 2), 10)
    array([[10, 10],
           [10, 10]])

    """
    if dtype is None:
        dtype = array(fill_value).dtype
    a = empty(shape, dtype, order)
    multiarray.copyto(a, fill_value, casting='unsafe')
    return a
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Dontla

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值