SHARE
TWEET

Untitled

a guest Jul 17th, 2016 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ●Ubuntu 16.04 LTSをインストール
  2.  
  3. ●端末(terminal)で以下を実行
  4. $ sudo apt-get install python-virtualenv
  5. $ cd $HOME
  6. $ virtualenv kabu
  7. $ cd kabu
  8. $ . bin/activate
  9. $ sudo apt-get install python-dev
  10. $ pip install pandas
  11.  
  12. ●reader.py作成
  13. -------- ここから  ----------
  14. from pandas.io.data import DataReader
  15. from datetime import datetime
  16.  
  17. end = datetime.now()
  18. start = datetime(end.year - 1, end.month, end.day)
  19. toyota = DataReader('TM', 'yahoo', start, end)
  20. print(toyota.head())
  21. -------- ここまで  ----------
  22. ※最後の行でprintしないと結果が表示されない。
  23.  
  24. ●reader.pyの実行
  25. $ cd $HOME/kabu
  26. $ . bin/activate
  27. $ python2 reader.py
  28. /home/yukke/kabu/local/lib/python2.7/site-packages/pandas/io/data.py:35: FutureWarning:
  29. The pandas.io.data module is moved to a separate package (pandas-datareader) and will be removed from pandas in a future version.
  30. 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``.
  31.   FutureWarning)
  32.                   Open        High         Low       Close  Volume   Adj Close
  33. Date                                                                          
  34. 2015-07-17  134.699997  135.490005  134.699997  135.360001  186100  135.360001
  35. 2015-07-20  135.789993  136.110001  135.410004  135.539993  352500  135.539993
  36. 2015-07-21  134.910004  135.029999  134.149994  134.559998  200500  134.559998
  37. 2015-07-22  133.800003  134.429993  133.800003  133.990005  196400  133.990005
  38. 2015-07-23  133.690002  133.919998  133.080002  133.250000  196100  133.250000
  39.  
  40.  
  41. ●端末での実行
  42. $ cd $HOME/kabu
  43. $ . bin/activate
  44. $ python2
  45. Python 2.7.11+ (default, Apr 17 2016, 14:00:29)
  46. [GCC 5.3.1 20160413] on linux2
  47. Type "help", "copyright", "credits" or "license" for more information.
  48. >>> from pandas.io.data import DataReader
  49. /home/yukke/kabu/local/lib/python2.7/site-packages/pandas/io/data.py:35: FutureWarning:
  50. The pandas.io.data module is moved to a separate package (pandas-datareader) and will be removed from pandas in a future version.
  51. 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``.
  52.   FutureWarning)
  53. >>> from datetime import datetime
  54. >>> end = datetime.now()
  55. >>> start = datetime(end.year - 1, end.month, end.day)
  56. >>> toyota = DataReader('TM', 'yahoo', start, end)
  57. >>> toyota.head()
  58.                   Open        High         Low       Close  Volume   Adj Close
  59. Date                                                                          
  60. 2015-07-17  134.699997  135.490005  134.699997  135.360001  186100  135.360001
  61. 2015-07-20  135.789993  136.110001  135.410004  135.539993  352500  135.539993
  62. 2015-07-21  134.910004  135.029999  134.149994  134.559998  200500  134.559998
  63. 2015-07-22  133.800003  134.429993  133.800003  133.990005  196400  133.990005
  64. 2015-07-23  133.690002  133.919998  133.080002  133.250000  196100  133.250000
  65. >>>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top