ipython笔记本启动文件

时间:2015-07-23 21:21:47

标签: pandas ipython ipython-notebook

我在〜/ .ipython / profile_default /启动位置有以下启动:

import sys, os
sys.path.append(os.environ["PYTHONPATH"])
import pandas as pd
pd.set_option("display.max_columns", 999)
pd.set_option("display.max_rows", 999)
pd.set_option("precision", 5)

现在出于某种原因,PYTHONPATH正在运行,但熊猫显示选项却没有。您推荐的任何我试图解决问题的方法吗?

1 个答案:

答案 0 :(得分:2)

您可以将以下内容放入~/.ipython/profile_default/ipython_config.py文件中。当您在命令行ipython notebook中启动笔记本时,它会自动执行。我认为有用的一些选项:

# Configuration file for ipython.

c = get_config()

c.InteractiveShellApp.exec_lines = [
    'from __future__ import print_function, division',
    '%matplotlib inline',
    'import sys, os',
    'sys.path.append(os.environ[\'PYTHONPATH\'])',
    'os.chdir(\'path/to/your/working/dir\')',    
    'import pandas as pd',
    'import numpy as np',    
    'pd.options.display.notebook_repr_html = False',
    'pd.options.display.max_rows = 20',
    'pd.options.display.max_columns = 20',
    'pd.options.display.expand_frame_repr = False',
    'pd.options.display.max_colwidth = 28',
    'pd.options.display.precision = 5',
    'np.set_printoptions(precision=4, linewidth=90, threshold=25)',
    'import datetime as dt',
    'import matplotlib.pyplot as plt'
]
c.NotebookApp.notebook_dir = u'path/to/your/notebook/dir'
c.IPythonWidget.font_size = 12
c.IPythonWidget.font_family = "Ubuntu Mono"
c.ZMQInteractiveShell.colors = "LightBG"