zoukankan      html  css  js  c++  java
  • pandas

    1. initializing NumPy array

    import numpy as np
    #convert list to array  
    a = np.array([0, 1, 2])
    #Create a 3x3 array of all zeros
    b = np.zeros((3,3))
    #Create a 2x2 array of all ones         
    c = np.ones(2,2) 
    #Create a 3x3 constant array        
    d = np.full((3,3),7) 
    #Create a 3x3 array filled with random values          
    e = np.random.random((3,3)) 
    #Crate a 3 * 3 identity matrix 
    f = np.eye(3)
    #convert list to array             
    g = np.array([2, 3, 1, 0])     
    # arange() will create arrays with regularly incrementing values     
    h = np.arange(20)         
    i = np.array([[0, 1,2.0],[0,0,0],(1+1j,3.,2.)])
    # create an array of range with float data type
    j = np.arange(1, 8, dtype=np.float) 
    # linspace() will create arrays with a specified number of items which are
    # spaced equally between the specified beginning and end values
    k = np.linspace(2., 4., 5)
    # Force a particular datatype
    z = np.array([5, 6], dtype=np.int64)
    print(z.dtype,k.dtype)
    

      

  • 相关阅读:
    awk
    django教材
    saltstack的安装过程
    OPENSTACK学习笔记(1)
    5G核心网架构
    内存采集
    分析CPU文件
    环境管理系统
    属性的两种定义方式
    Python 面向对象(初级篇)
  • 原文地址:https://www.cnblogs.com/ordili/p/9291635.html
Copyright © 2011-2022 走看看