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,:])

  • 相关阅读:
    VUE body 背景色
    BUTTON莫名出现黄色边框 :focus
    VUE SVG
    【噶】字符串-680. 验证回文字符串 Ⅱ
    【噶】数组-两数之和(哈希表)
    【噶】数组-面试题 16.11. 跳水板
    【噶】字符串-58. 最后一个单词的长度
    Ajax_Jason 使用小Demo
    tomcat_部署项目以及相关问题
    js 表单的选择与反选简单操作
  • 原文地址:https://www.cnblogs.com/zijidefengge/p/14009797.html
Copyright © 2011-2022 走看看