zoukankan      html  css  js  c++  java
  • np.repeat()

    np.repeat()用于将numpy数组重复。

    numpy.repeat(a, repeats, axis=None);

    参数:

    axis=0,沿着y轴复制,实际上增加了行数
    axis=1,沿着x轴复制,实际上增加了列数

    1. 一维数组重复3次

    # 随机生成[0, 5)之间的数,形状1行4列,将此数组按y轴重复3次
    import numpy as np
    pop = np.random.randint(0, 5, size=(1, 4)).repeat(3, axis=0)
    print(pop)

    2. 二维数组在第一维和第二维分别重复3次

    # 二维数组在第一维和第二维分别重复3次
    pop_reshape = pop.reshape(2, 6)
    pop_reshape_repeataxis0 = pop_reshape.repeat(3, axis=0)
    pop_reshape_repeataxis1 = pop_reshape.repeat(3, axis=1)
    print(pop_reshape)
    print(pop_reshape_repeataxis0)
    print(pop_reshape_repeataxis1 )

     来自:https://blog.csdn.net/u013555719/article/details/83855965

  • 相关阅读:
    5.5 数据库约束
    5.4 数据库数据类型
    5.3 数据 库,表 操作
    5.2 数据库引擎
    5.1 数据库安装
    4.6 并发编程/IO模型
    4.5 协程
    4.4 线程
    在线编辑器 引入方法
    MySQL查看版本号的五种方式介绍1111111
  • 原文地址:https://www.cnblogs.com/keye/p/11246807.html
Copyright © 2011-2022 走看看