zoukankan      html  css  js  c++  java
  • np.where np.linspace() 查看行数与列数 (numpy,pandas,R python)

    a = np.linspace(b,c,d)       b 为开始点, c 为终点, d 为一共多少个数,  对于 a 的切片可以按照列表的切片

    re = np.where(矩阵)

    可以看出,他用第一行来表示行数,第二行来表示列数,结果返回的是索引值

    >>> print(b)
    [[ 0 1 2 3 4 5 6 7 8]
    [ 9 10 11 12 13 14 15 16 17]
    [18 19 20 21 22 23 24 25 26]]
    >>> res = np.where(b>4)
    >>> print(res)
    (array([0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2],dtype=int64),

    array([5, 6, 7, 8, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 1, 2, 3, 4, 5, 6, 7, 8],dtype=int64))


    >>> res
    (array([0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2],dtype=int64),

    array([5, 6, 7, 8, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 1, 2, 3, 4, 5, 6, 7, 8],dtype=int64))
    >>>

    numpy    查看行列数     data.shape 这里没有小括号         data.shape[0]  行数    data.shape[1]  列数

    pandas      查看行列列数        df.shape  这里没有小括号

    R             查看行列数            nrow(data)   ncol(data)

                rownames(data)  查看行名 

                dim(data)        dim(data)[0]    dim(data)[1]

                 length(data)       length(data[:,1])   length(data[1,:])

  • 相关阅读:
    C# treeView添加节点 删除节点
    xml 基础
    第一章魔兽窗口
    混合开发的框架的初步见解
    node.js的初步见解
    AngularJs的理解
    jquery属性,遍历,HTML操作
    jquery中动画效果的函数
    jquery的选择器
    js操作DOM对象及怎么获取浏览器宽高
  • 原文地址:https://www.cnblogs.com/zijidefengge/p/14009797.html
Copyright © 2011-2022 走看看