- pip install pandas
C:\JS>pip install pandas
Collecting pandas
Downloading pandas-0.19.2-cp36-cp36m-win_amd64.whl (7.2MB)
100% |████████████████████████████████| 7.2MB 120kB/s
Collecting pytz>=2011k (from pandas)
Downloading pytz-2016.10-py2.py3-none-any.whl (483kB)
100% |████████████████████████████████| 491kB 857kB/s
Collecting numpy>=1.7.0 (from pandas)
Downloading numpy-1.12.0-cp36-none-win_amd64.whl (7.7MB)
100% |████████████████████████████████| 7.7MB 126kB/s
Collecting python-dateutil>=2 (from pandas)
Downloading python_dateutil-2.6.0-py2.py3-none-any.whl (194kB)
100% |████████████████████████████████| 194kB 2.1MB/s
Requirement already satisfied: six>=1.5 in c:\users\chang\appdata\local\programs\python\python36\lib\site-packages (from pytho
n-dateutil>=2->pandas)
Installing collected packages: pytz, numpy, python-dateutil, pandas
Successfully installed numpy-1.12.0 pandas-0.19.2 python-dateutil-2.6.0 pytz-2016.10
如果想完成pandas主页上的测试项目,还需要安装nose包。
C:\JS>pip install nose
Collecting nose
Downloading nose-1.3.7-py3-none-any.whl (154kB)
100% |████████████████████████████████| 163kB 169kB/s
Installing collected packages: nose
Successfully installed nose-1.3.7
测试一下是否成功安装。
C:\JS>python
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>> pd.test()
Running unit tests for pandas
pandas version 0.19.2
numpy version 1.12.0
pandas is installed in C:\Users\*****\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas
Python version 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)]
nose version 1.3.7
C:\Users\*****\AppData\Local\Programs\Python\Python36\lib\imp.py:216: FutureWarning: The pandas.rpy module is deprecated and w
ill be removed in a future version. We refer to external packages like rpy2.
See here for a guide on how to port your code to rpy2: http://pandas.pydata.org/pandas-docs/stable/r_interface.html
return _load(spec)
.........SSS..SS..SS..SS..SS..SS..SS..SS..SSSSSSSSSSSSSS.
- 安装lxml
C:\JS>pip install lxml
Collecting lxml
Downloading lxml-3.7.2-cp36-cp36m-win_amd64.whl (3.2MB)
100% |████████████████████████████████| 3.2MB 272kB/s
Installing collected packages: lxml
Successfully installed lxml-3.7.2
- 安装requests
C:\JS>pip install requests
Collecting requests
Downloading requests-2.13.0-py2.py3-none-any.whl (584kB)
100% |████████████████████████████████| 593kB 1.2MB/s
Installing collected packages: requests
Successfully installed requests-2.13.0
- 安装tushare
C:\JS>pip install tushare
Collecting tushare
Downloading tushare-0.6.8.tar.gz (87kB)
100% |████████████████████████████████| 92kB 304kB/s
Installing collected packages: tushare
Running setup.py install for tushare ... done
Successfully installed tushare-0.6.8
- 测试是否成功安装
C:\JS>python
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tushare as ts
>>> ts.get_k_data('399300', index=True,start='2016-10-01', end='2017-01-31')
date open close high low volume code
184 2016-10-10 3265.36 3293.87 3294.64 3258.96 80519260.0 sz399300
185 2016-10-11 3296.87 3306.56 3308.00 3292.88 87713163.0 sz399300
186 2016-10-12 3299.14 3300.01 3302.56 3289.75 68669781.0 sz399300
187 2016-10-13 3299.16 3302.65 3307.41 3292.40 81224198.0 sz399300
188 2016-10-14 3298.73 3305.85 3306.69 3285.73 82316271.0 sz399300
...
258 2017-01-23 3359.05 3364.08 3378.74 3355.85 75557498.0 sz399300
259 2017-01-24 3363.14 3364.45 3371.32 3355.90 66194226.0 sz399300
260 2017-01-25 3361.66 3375.90 3376.44 3357.22 58376931.0 sz399300
261 2017-01-26 3378.26 3387.96 3395.88 3378.26 65316647.0 sz399300
- 安装seaborn绘图库
在http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy 下载scipy‑0.18.1‑cp36‑cp36m‑win_amd64.whl文件和numpy‑1.12.0+mkl‑cp36‑cp36m‑win_amd64.whl文件。
因为pandas安装的numpy不符合scipy的要求,所以需要卸载后重新安装一个附带Intel® Math Kernel Library 库的版本
C:\JS>pip uninstall numpy
Proceed (y/n)? y
Successfully uninstalled numpy-1.12.0
C:\JS>pip install "c:\js\numpy-1.12.0+mkl-cp36-cp36m-win_amd64.whl"
Processing c:\js\numpy-1.12.0+mkl-cp36-cp36m-win_amd64.whl
Installing collected packages: numpy
Successfully installed numpy-1.12.0+mkl
C:\JS>pip install "c:\js\scipy-0.18.1-cp36-cp36m-win_amd64.whl"
Processing c:\js\scipy-0.18.1-cp36-cp36m-win_amd64.whl
Installing collected packages: scipy
Successfully installed scipy-0.18.1
都准备好了再安装seaborn
C:\JS>pip install seaborn
Collecting seaborn
Using cached seaborn-0.7.1.tar.gz
Collecting matplotlib (from seaborn)
Using cached matplotlib-2.0.0-cp36-cp36m-win_amd64.whl
Requirement already satisfied: python-dateutil in c:\users\chang\appdata\local\programs\python\python36\lib\site-packages (fro
m matplotlib->seaborn)
Collecting cycler>=0.10 (from matplotlib->seaborn)
Using cached cycler-0.10.0-py2.py3-none-any.whl
Requirement already satisfied: six>=1.10 in c:\users\chang\appdata\local\programs\python\python36\lib\site-packages (from matp
lotlib->seaborn)
Requirement already satisfied: pytz in c:\users\chang\appdata\local\programs\python\python36\lib\site-packages (from matplotli
b->seaborn)
Requirement already satisfied: numpy>=1.7.1 in c:\users\chang\appdata\local\programs\python\python36\lib\site-packages (from m
atplotlib->seaborn)
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=1.5.6 (from matplotlib->seaborn)
Using cached pyparsing-2.1.10-py2.py3-none-any.whl
Installing collected packages: cycler, pyparsing, matplotlib, seaborn
Running setup.py install for seaborn ... done
Successfully installed cycler-0.10.0 matplotlib-2.0.0 pyparsing-2.1.10 seaborn-0.7.1
- 我们测试一下是否能用了
import matplotlib.pyplot as plt
import seaborn as sns
import seaborn.linearmodels as snsl
import tushare as ts
sns.set_style("whitegrid")
stock = ts.get_hist_data('300104', '2016-01-01', '2017-01-31')
stock['close'].plot(legend=True, figsize=(10, 4))
plt.show()
完美~或者说,能用了