ipython Notebook Pandas Max允许的列 [英] ipython notebook pandas max allowable columns
问题描述
我有一个简单的csv文件,其中包含十列!
I have a simple csv file with ten columns!
当我在笔记本中设置以下选项并打印我的csv文件(位于pandas数据框中)时,它不会从左到右打印所有列,而是打印前两列,下两列,依此类推上.
When I set the following option in the notebook and print my csv file (which is in a pandas dataframe) it doesn't print all the columns from left to right, it prints the first two, the next two underneath and so on.
我使用了此选项,为什么它不起作用?
I used this option, why isn't it working?
pd.option_context("display.max_rows",1,"display.max_columns",100)
即使这似乎不起作用:
pandas.set_option('display.max_columns', None)
推荐答案
我假设您要在笔记本中显示数据,但以下选项对我来说效果很好(IPython 2.3):
I assume you want to display your data in the notebook than the following options work fine for me (IPython 2.3):
import pandas as pd
from IPython.display import display
data = pd.read_csv('yourdata.txt')
直接设置选项
pd.options.display.max_columns = None
display(data)
或者,使用您显示的set_option方法也可以正常工作
Or, use the set_option method you showed actually works fine as well
pd.set_option('display.max_columns', None)
display(data)
如果您不想为整个脚本设置此选项,请使用上下文管理器
If you don't want to set this options for the whole script use the context manager
with pd.option_context('display.max_columns', None):
display(data)
如果这没有帮助,您可以举一个最小的例子来重现您的问题.
If this doesn't help, you might give a minimal example to reproduce your issue.
这篇关于ipython Notebook Pandas Max允许的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!