python 資料分析

來源:互聯網
上載者:User

標籤:預設   隨機數   隨機   items   自動識別   col   sha   大小   and   

import numpy as nplist = [[1,3,5,7],[2,4,6,8]]np_list = np.array(list)    #將l列表資料轉化為數群組類型print(np_list)‘‘‘[[1 3 5 7] [2 4 6 8]]‘‘‘np_list1 = np.array(list,dtype=np.float) # 通過dtype定義數組的類型,預設的自動識別print(np_list1)                          #bool,int,int8,int32,int16,int64,int128,uint8等,float。float16/32/等‘‘‘[[ 1.  3.  5.  7.] [ 2.  4.  6.  8.]]‘‘‘#資料的屬性print(np_list.shape)          # (2, 4) 兩行四列print(np_list.ndim)           # 2      資料的維度print(np_list.dtype)          # int32  數組的類型print(np_list.itemsize)       # 4      每個資料的大小print(np_list.size)           # 8      資料的個數# 一些數組 some arraysprint(np.ones((3,5)))‘‘‘[[ 1.  1.  1.  1.  1.] [ 1.  1.  1.  1.  1.] [ 1.  1.  1.  1.  1.]]‘‘‘                 print(np.zeros((2,4)))‘‘‘[[ 0.  0.  0.  0.] [ 0.  0.  0.  0.]]‘‘‘ # 隨機數# randprint(np.random.rand(2,4))    #產生一個兩行四類的隨機數‘‘‘[[ 0.72024033  0.93403506  0.73121086  0.84075394] [ 0.98034306  0.6471637   0.77923702  0.44984363]]‘‘‘print(np.random.rand())              # 0.702153504735015  一個隨機數# randintprint(np.random.randint(1,10))      # 必須要填入數字範圍print(np.random.randint(1,10,3))    # 前面兩個數字是範圍,後面的一是輸出的隨機數個數# randn 標準動態產生的隨機數print(np.random.randn())           # 0.2021606168747088print(np.random.randn(2,4))        # 兩行四列的正態隨機數‘‘‘[[-0.43522053  0.288716    1.5751424  -0.89094638] [-1.12602864  1.27198812 -0.4784293   1.90768013]]‘‘‘# choice  隨機產生 制定數組內的 隨機數print(np.random.choice([10,20,30]))     # 隨機產生一個隨機數print(np.random.choice([10,20,30],2))   # 隨機產生制定個隨機數# 數學函數的分布print(np.random.beta(1,10,100))         # beta函數的分布

 

python 資料分析

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.