PyInv

プログラミングのメモ、海外投資のメモ

Jupyter Env Note

Memorandam of Jupyter Setup

どんな設定か忘れないように(バージョンはきにしない)

Packages

pipよりcondaが好き

  • pandas
  • pandas-datareader
    • 使えないソースが増えてきている(yahoo Finance, Google Finance)ので注意
  • matplotlib
    • おなじみのMatlab式図形描写
  • seaborn
    • 統計に特化した描写
  • bokeh
    • matplotlib よりも細かい図形描写
  • ipywidgets, plotly
  • scikit-learn
  • scipy
  • statsmodels
    • 統計テスト
  • sqlalchemy
    • pandasのread_sqlに簡単にデータを渡せるDB Con用のツール
  • xlrd, xlwt
    • excelデータを取得
  • lxml, beautifulsoup4, html5lib
    • htmlのweb scraping用
  • pydotplus, graphviz
    • Decision Treeの可視化用

Packages 2

condaのdefaultにないもの

  • Nbextention
    • まずはconda-forgeを追加)
conda config --add channels conda-forge
    • 追加されたことを確認
conda config --get channels
--add channels 'conda-forge'   # lowest priority
    • インストール
conda install -c conda-forge jupyter_contrib_NbExtensions
  • fitter
    • 分布の形状を判別してくれる
conda config --add channels bioconda
conda install fitter

Japanese

特にmatplotlibでの日本語表示用にrcParamsを設定する(つまりNotebookごと)

import os
from matplotlib import rcParams
rcParams['font.sans-serif']='' #日本語表示を含むフォントを指定



もしくはmatplotlibrcを編集(matplotlibのデフォルトにする)

#現在のmatplotlibrcのパスを調べて
from matplotlib import matplotlib_fname
matplotlib.fname()
  
#現在のmatplotlibrcのコピーをとっておき
import shutil
shutil.copyfile(matplotlib_fname(), 'matplotlibrc')

#ファイルを直接書き換え後、キャッシュのクリア
from matplotlib import matplotlib_font_manager
font_manager._rebuild()