启动时Pandas和NumPy默认宽度更改 [英] Pandas and NumPy default width change on startup

查看:339
本文介绍了启动时Pandas和NumPy默认宽度更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在启动IPython shell时指定Pandas和NumPy显示宽度。例如,

Is there a way to specify Pandas and NumPy display width on startup of an IPython shell. For example,

# Run this at startup
import numpy as np
np.set_printoptions(linewidth=200)

import pandas as pd
pd.options.display.width = 200


推荐答案

对于Windows,对我来说,我有一个启动目录:

For Windows, for me, I have a startup directory:

'C:\Users\username\.ipython\profile_default\startup'

在此我创建了一个文件:

In this I create a file:

'00-script.py`

此目录中的文件将按名称的字母顺序运行。我把'00'放在前面以确保它先运行。在这个文件中,你要把:

Files in this directory will be run in alphabetical order by name. I put '00' in front to ensure it gets run first. In this file, you'd put:

import numpy as np
np.set_printoptions(linewidth=200)

import pandas as pd
pd.options.display.width = 200

检查文档以查看目录的位置。

Check documentation to see where your directory is.

文档

这篇关于启动时Pandas和NumPy默认宽度更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆