• Python数据分析与机器学习-NumPy_5


    import numpy as np
    data = np.sin(np.arange(20)).reshape(5,4)
    print(data)
    ind = data.argmax(axis=0)
    print(ind)
    data_max = data[ind,range(data.shape[1])]
    print(data_max)
    all(data_max == data.max(axis=0))
    
    [[ 0.          0.84147098  0.90929743  0.14112001]
     [-0.7568025  -0.95892427 -0.2794155   0.6569866 ]
     [ 0.98935825  0.41211849 -0.54402111 -0.99999021]
     [-0.53657292  0.42016704  0.99060736  0.65028784]
     [-0.28790332 -0.96139749 -0.75098725  0.14987721]]
    [2 0 3 1]
    [0.98935825 0.84147098 0.99060736 0.6569866 ]
    
    
    
    
    
    True
    
    a = np.arange(0,40,10)
    b = np.tile(a,(3,5))
    print(a)
    print(b)
    
    [ 0 10 20 30]
    [[ 0 10 20 30  0 10 20 30  0 10 20 30  0 10 20 30  0 10 20 30]
     [ 0 10 20 30  0 10 20 30  0 10 20 30  0 10 20 30  0 10 20 30]
     [ 0 10 20 30  0 10 20 30  0 10 20 30  0 10 20 30  0 10 20 30]]
    
    a = np.array([[4,3,5],[1,2,1]])
    print(a)
    b = np.sort(a,axis=1)
    print(b)
    a.sort(axis=1)
    print(a)
    print("---")
    a = np.array([4,3,1,2])
    j = np.argsort(a)
    print(j)
    print(a[j])
    
    [[4 3 5]
     [1 2 1]]
    [[3 4 5]
     [1 1 2]]
    [[3 4 5]
     [1 1 2]]
    ---
    [2 3 1 0]
    [1 2 3 4]
  • 相关阅读:
    Oracle分页SQL
    CentOS7下安装Anaconda3
    Alibaba分层领域模型规约
    java的continue标签
    SQLserver 及 redis 无法连接问题
    HTTP状态码
    java命令功能
    sql 查询结果自增序号
    Viewpage实现左右无限滑动
    Android OOM 问题的总结
  • 原文地址:https://www.cnblogs.com/SweetZxl/p/11124179.html
Copyright © 2020-2023  润新知