Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ●Ubuntu 16.04 LTSをインストール
- ●端末(terminal)で以下を実行
- $ sudo apt-get install python-virtualenv
- $ cd $HOME
- $ virtualenv kabu
- $ cd kabu
- $ . bin/activate
- $ sudo apt-get install python-dev
- $ pip install pandas
- ●reader.py作成
- -------- ここから ----------
- from pandas.io.data import DataReader
- from datetime import datetime
- end = datetime.now()
- start = datetime(end.year - 1, end.month, end.day)
- toyota = DataReader('TM', 'yahoo', start, end)
- print(toyota.head())
- -------- ここまで ----------
- ※最後の行でprintしないと結果が表示されない。
- ●reader.pyの実行
- $ cd $HOME/kabu
- $ . bin/activate
- $ python2 reader.py
- /home/yukke/kabu/local/lib/python2.7/site-packages/pandas/io/data.py:35: 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``.
- FutureWarning)
- Open High Low Close Volume Adj Close
- Date
- 2015-07-17 134.699997 135.490005 134.699997 135.360001 186100 135.360001
- 2015-07-20 135.789993 136.110001 135.410004 135.539993 352500 135.539993
- 2015-07-21 134.910004 135.029999 134.149994 134.559998 200500 134.559998
- 2015-07-22 133.800003 134.429993 133.800003 133.990005 196400 133.990005
- 2015-07-23 133.690002 133.919998 133.080002 133.250000 196100 133.250000
- ●端末での実行
- $ cd $HOME/kabu
- $ . bin/activate
- $ python2
- Python 2.7.11+ (default, Apr 17 2016, 14:00:29)
- [GCC 5.3.1 20160413] on linux2
- Type "help", "copyright", "credits" or "license" for more information.
- >>> from pandas.io.data import DataReader
- /home/yukke/kabu/local/lib/python2.7/site-packages/pandas/io/data.py:35: 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``.
- FutureWarning)
- >>> from datetime import datetime
- >>> end = datetime.now()
- >>> start = datetime(end.year - 1, end.month, end.day)
- >>> toyota = DataReader('TM', 'yahoo', start, end)
- >>> toyota.head()
- Open High Low Close Volume Adj Close
- Date
- 2015-07-17 134.699997 135.490005 134.699997 135.360001 186100 135.360001
- 2015-07-20 135.789993 136.110001 135.410004 135.539993 352500 135.539993
- 2015-07-21 134.910004 135.029999 134.149994 134.559998 200500 134.559998
- 2015-07-22 133.800003 134.429993 133.800003 133.990005 196400 133.990005
- 2015-07-23 133.690002 133.919998 133.080002 133.250000 196100 133.250000
- >>>
Add Comment
Please, Sign In to add comment