zoukankan      html  css  js  c++  java
  • 【numpy】使用笔记

    记录贴。

    参考:

    NumPy是使用Python进行科学计算的基础软件包。包括:1)功能强大的N维数组对象。2)精密广播功能函数。3)集成C/C+和Fortran代码的工具。4)强大的线性代数、傅立叶变换和随机数功能。

    • NumPy 最重要的一个特点是其 N 维数组对象 ndarray,它是一系列同类型数据的集合,以 0 下标为开始进行集合中元素的索引。ndarray 对象是用于存放同类型元素的多维数组。ndarray 中的每个元素在内存中都有相同存储大小的区域。
    • ndarray对象的内容可以通过索引或切片来访问和修改,与 Python 中 list 的切片操作一样。ndarray 数组可以基于 0 - n 的下标进行索引,切片对象可以通过内置的 slice 函数,并设置 start, stop 及 step 参数进行,从原数组中切割出一个新数组。
    import numpy as np
    

    数据拼接

    非系统性总结,持续更新……

    np.column_stack(tup)

    Stack 1-D arrays as columns into a 2-D array.
    Take a sequence of 1-D arrays and stack them as columns to make a single 2-D array. 2-D arrays are stacked as-is, just like with hstack. 1-D arrays are turned into 2-D columns first.

    • [Parameters]: tup, sequence of 1-D or 2-D arrays. Arrays to stack. All of them must have the same first dimension.
    • [Returns]: stacked, 2-D array. The array formed by stacking the given arrays.

    np.hstack(tup)

    Stack arrays in sequence horizontally (column wise).
    This is equivalent to concatenation along the second axis, except for 1-D arrays where it concatenates along the first axis.
    This function makes most sense for arrays with up to 3 dimensions. For instance, for pixel-data with a height (first axis), width (second axis), and r/g/b channels (third axis).

    Similarly, np.vstack(tup): Stack arrays in sequence vertically (row wise).

    np.concatenate()

    np.concatenate((a1, a2, ...), axis=0, out=None, dtype=None, casting="same_kind"), Join a sequence of arrays along an existing axis.

    Tips

    UserWarning: loaded more than 1 DLL from .libs: 【参考:numpy版本问题

  • 相关阅读:
    C++11学习笔记
    孙鑫MFC学习笔记20:Hook编程
    孙鑫MFC学习笔记19:动态链接库
    孙鑫MFC学习笔记18:ActiveX
    孙鑫MFC学习笔记17:进程间通信
    孙鑫MFC学习笔记16:异步套接字
    孙鑫MFC学习笔记:15多线程
    ionic2 使用slides制作滑动效果的类型选择栏
    JavaScript简明教程之Node.js
    ionic2实战-使用Chart.js
  • 原文地址:https://www.cnblogs.com/ytxwzqin/p/14411702.html
Copyright © 2011-2022 走看看