2016年7月16日 星期六

用python抓股價---在Windows上安裝Python Pandas套件


--------------------------------------------------------------------
import pandas as pd
import pandas.io.data as web
import datetime as dt

start=dt.datetime(2013,1,1)

end=dt.date.today()

AAPL=web.DataReder('AAPL','yahoo',start,end)
----------------------------------------------------------------------
執行後缺東缺西
金害

OS:WINDOWS 10 64BIT
python:3.5

首先以系統管理員開啟"命令提示字元"
輸入:pip install pandas
ENTER後,跑一段時間會出現
You are using pip version 8.1.1, however version 8.1.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
跟著執行
python -m pip install --upgrade pip
即可完成安裝。


執行後還是不行
Warning (from warnings module):
  File "C:\Users\lee-msi1\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pandas\io\data.py", line 35
    FutureWarning)
FutureWarning:
The pandas.io.data module is moved to a separate package (pandas-datareader) and will be removed from pandas in a future version.
After installing the pandas-datareader package (https://github.com/pydata/pandas-datareader), you can change the import ``from pandas.io import data, wb`` to ``from pandas_datareader import data, wb``.
Traceback (most recent call last):
  File "R:/getprice.py", line 9, in <module>
    AAPL=web.DataReder('AAPL','yahoo',start,end)
AttributeError: module 'pandas.io.data' has no attribute 'DataReder'

繼續在"命令提示字元"執行pip install pandas-datareader
---------------------------------------------------------------------------------------------------
import pandas as pd
import pandas_datareader as web
import datetime as dt

start=dt.datetime(2013,1,1)

end=dt.date.today()

AAPL=web.DataReder('AAPL','yahoo',start,end)

print (AAPL)
-----------------------------------------------------------------------------------------------------
執行後OK:



投資要靠自己 聽明牌就是把錢送別人

沒有留言:

張貼留言

歡迎留言<