標籤:地址 安裝 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及簡單應用