zoukankan      html  css  js  c++  java
  • numpy——>数组拼接np.concatenate

    语法:

      np.concatenate((a1, a2, ...), axis=0)

      1、默认是 axis = 0,也就是说对0轴(行方向)的数组对象,进行其垂直方向(axis=1)的拼接(即数据整行整行地沿列方向向前推进合并)

      2、传入的数组必须具有相同的形状,即满足在拼接方向axis轴上数组间的形状一致,比如:数组形状(3*4),当axis=0时,也就是推进拼接的方向是列方向,即需要保证有4列

    示例:

    1 In [1]: a = np.array([[1, 2], [3, 4]])
    2 In [2]: b = np.array([[5, 6]])
    3 In [3]: np.concatenate((a, b), axis=0)
    4 Out[3]:
    5         array([[1, 2],
    6                [3, 4],
    7                [5, 6]])
    View Code

     

     

  • 相关阅读:
    CF1270H
    CF1305G
    LeetCode-Sqrt(x)
    LeetCode-Plus One
    LeetCode-Integer to Roman
    LeetCode-Roman to Integer
    LeetCode-String to Integer (atoi)
    LeetCode-Reverse Integer
    C++
    LeetCode-Gray Code
  • 原文地址:https://www.cnblogs.com/raykindle/p/12485250.html
Copyright © 2011-2022 走看看