Windows下下載及安裝numpy、pandas及簡單應用

來源:互聯網
上載者:User

標籤:地址   安裝   out   das   panda   pac   win   是的   none   

下載numpy

  • https://pypi.python.org/pypi/numpy
    進入網站,下載和自己電腦及電腦中安裝的python匹配的numpy版本。我的電腦是Win 10 x64位的系統,裝的python版本是3.6,則要下載numpy-1.13.1-cp36-none-win_amd64.whl

  • 安裝
    把剛剛下載的.whl檔案放在任意檔案夾下,然後進入該檔案夾的目錄開啟命令列,然後使用pip指令安裝(前提是你的電腦已經安裝了python的pip包管理模組),輸入命令:

    pip install numpy-1.13.1-cp36-none-win_amd64.whl

  • 測試,使用random函數來進行驗證
    引用《機器學習實戰》的測試例子:

    >>> from numpy import *>>> random.rand(3,3)

  • 簡單應用
    如何將我們下載的numpy模組用到python程式文法中呢?首先我們得引入該模組:

    #引入numpy模組import numpy as np;#numpy 建立數組a = np.array([1, 2, 3, 4, 5]);b = np.array((1, 2, 3, 4, 5));d = np.linspace(0, 2*np.pi, 5);print(a);print(b);print(d);# [1 2 3 4 5]# [1 2 3 4 5]# [ 0.          1.57079633  3.14159265  4.71238898  6.28318531]#建立多維陣列c = np.array([[1,2,3,4],             [5,6,7,8],             [11,12,13,14],             [15,16,17,81],             ]);print(c);print(c[2,3]);# [[ 1  2  3  4]#  [ 5  6  7  8]#  [11 12 13 14]#  [15 16 17 81]]# 14
安裝pandas

python的pandas模組和numpy模組都是用於科學計算的模組。我看了很多pandas安裝的教程,都有一些前提條件:什麼numpy的版本要新、要下什麼python的什麼包啊,先下載鏡像啊,網速要好(這個的確是的)這些的,五花八門的,但是我就是先下了python、pip模組、numpy然後用命令列輸入命令下載的:

pip3 install pandas

下載好之後,就能使用了

import pandas as pd;a2 = pd.Series([1,3,5,np.nan,6,8]);print(a2);# 0    1.0# 1    3.0# 2    5.0# 3    NaN# 4    6.0# 5    8.0# dtype: float64

Windows下下載及安裝numpy、pandas及簡單應用

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.