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


    import numpy as np
    B = np.arange(3)
    print(B)
    print(np.exp(B))
    print(np.sqrt(B))
    
    [0 1 2]
    [1.         2.71828183 7.3890561 ]
    [0.         1.         1.41421356]
    
    # Return the floor of the input
    
    a = np.floor(10*np.random.random((3,4)))
    print(a)
    print(a.shape)
    # flatten the array
    print(a.ravel())
    print(a)
    print(a.T)
    print(a.resize((2,6)))
    print(a)
    
    [[6. 7. 8. 7.]
     [3. 8. 6. 7.]
     [0. 4. 2. 1.]]
    (3, 4)
    [6. 7. 8. 7. 3. 8. 6. 7. 0. 4. 2. 1.]
    [[6. 7. 8. 7.]
     [3. 8. 6. 7.]
     [0. 4. 2. 1.]]
    [[6. 3. 0.]
     [7. 8. 4.]
     [8. 6. 2.]
     [7. 7. 1.]]
    None
    [[6. 7. 8. 7. 3. 8.]
     [6. 7. 0. 4. 2. 1.]]
    
    a = np.floor(10*np.random.random((2,2)))
    b = np.floor(10*np.random.random((2,2)))
    print(a)
    print("---")
    print(b)
    print("---")
    print(np.hstack((a,b)))
    print("---")
    print(np.vstack((a,b)))
    
    [[7. 3.]
     [5. 8.]]
    ---
    [[6. 6.]
     [0. 4.]]
    ---
    [[7. 3. 6. 6.]
     [5. 8. 0. 4.]]
    ---
    [[7. 3.]
     [5. 8.]
     [6. 6.]
     [0. 4.]]
    
    a = np.floor(10*np.random.random((2,12)))
    print(a)
    print(np.hsplit(a,3))
    print(np.hsplit(a,(3,4)))
    a = np.floor(10*np.random.random((12,2)))
    print(a)
    np.vsplit(a,3)
    
    [[2. 2. 7. 1. 9. 6. 5. 6. 9. 1. 9. 8.]
     [7. 6. 4. 7. 4. 3. 9. 2. 8. 5. 3. 4.]]
    [array([[2., 2., 7., 1.],
           [7., 6., 4., 7.]]), array([[9., 6., 5., 6.],
           [4., 3., 9., 2.]]), array([[9., 1., 9., 8.],
           [8., 5., 3., 4.]])]
    [array([[2., 2., 7.],
           [7., 6., 4.]]), array([[1.],
           [7.]]), array([[9., 6., 5., 6., 9., 1., 9., 8.],
           [4., 3., 9., 2., 8., 5., 3., 4.]])]
    [[5. 9.]
     [7. 9.]
     [4. 5.]
     [2. 7.]
     [6. 0.]
     [1. 5.]
     [1. 9.]
     [9. 0.]
     [3. 3.]
     [3. 7.]
     [0. 8.]
     [1. 1.]]
    
    
    
    
    
    [array([[5., 9.],
            [7., 9.],
            [4., 5.],
            [2., 7.]]), array([[6., 0.],
            [1., 5.],
            [1., 9.],
            [9., 0.]]), array([[3., 3.],
            [3., 7.],
            [0., 8.],
            [1., 1.]])]
  • 相关阅读:
    Binder机制1---Binder原理介绍
    ShareSDK for iOS 2.9.0已经公布
    TCP/IP数据包结构具体解释
    苹果ipa软件包破解笔记
    自己定义对象的监听方式
    强大的PropertyGrid
    matlab中plot使用方法
    fopen 參数具体解释
    leetcode:linked_list_cycle_II
    AssemblyInfo.cs文件的作用
  • 原文地址:https://www.cnblogs.com/SweetZxl/p/11124175.html
Copyright © 2020-2023  润新知