• ndarray多维数组


    创建ndarray数组

    1.       通过列表创建ndarray数组

     

    2.       通过元祖创建ndarray数组

     

    3.       创建多维数组

     

    4.       zeros函数

     

    5.       ones函数

     

    6.       empty函数

     

    7.       arange函数

     

    ndarray对象属性

    .ndim            数据轴的个数

    .shape          数组的维度

    .size              元素的总个数

    .dtype           数据类型

    .itemsize        数组中每个元素的字节大小

     

    ndarray数组类型

    通过数组的astype方法进行类型转换

    第一种方法:

     

    第二种方法:

     

    浮点数转整数,小数部分会被截断

     

    全数字类型的字符串转数组

     

    通过另外一个数组的type进行转换

     

    数组变换

    1.       数组重塑(reshape)

     

      a)       散开(ravel)

     

      b)       扁平化(flatten)

     

    2.       数组合并(concatenate)

     

      a)       vstack

     

      b)       hstack

     

    3.       数组拆分(split)

     

    4.       数组转置(T)和轴对换(swapaxes)

     

     

    ndarray的随机数函数

    rand                                    产生均匀分布的样本值

    randint                                给定范围内取随机整数

    randn                                  产生正态分布的样本值

    seed                                    随机数种子

    permutation                       对一个序列随机排序,不改变原数组

    shuffle                                  对一个序列随机排序,改变原数组

    uniform(low,high,size)        产生具有均匀分布的数组,low表示起始值,high表示结束值,size表示形状

    normal(low,scale,size)        产生具有正态分布的数组,loc表示均值,scale表示标准差

    poisson(lam,size)                产生具有泊松分布的数组,lam表示随机事件发生率

     

    randint函数

     

    randn函数

     

    normal函数

     

    Permutation函数

     

    shuffle函数

     

    学习中,博客都是自己学习用的笔记,持续更新改正。。。
  • 相关阅读:
    codeforces 407B Long Path
    CodeForces 489C Given Length and Sum of Digits...
    hacker cup 2015 Round 1 解题报告
    hacker cup 2015 资格赛
    Codeforces 486(#277 Div 2) 解题报告
    POJ 3468 A Simple Problem with Integers splay
    Codeforces 484(#276 Div 1) D Kindergarten DP
    求平均值问题201308031210.txt
    I love this game201308022009.txt
    QQ
  • 原文地址:https://www.cnblogs.com/Tunan-Ki/p/11752633.html
Copyright © 2020-2023  润新知