且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

相当于R's View for Python's pandas

更新时间:2022-05-03 10:01:40

一个更快的选择可能是设置pandas数据框,以免通过以下代码行换行:

A quicker option might be to set the pandas dataframe so it doesn't line wrap by putting this line of code:

import pandas
pandas.set_option('expand_frame_repr', False)

我正在使用Sublime Text 2,这是它的外观:

I'm using Sublime Text 2 and this is how it looks:

放入选项之前(请注意输出如何环绕文字)

Before putting in option (Notice how the output wraps the text around)

放入选项后(注意输出如何继续)

After putting in option (Notice how the output continues)

还请确保未选中查看">自动换行".

Also make sure that 'View' > 'Word Wrap' is not checked.

另外,您可以通过使用 head(#)这样根据需要打印更多或更少的内容:

Additionally, you can print out more or less as you need by using head(#) like this:

mydf = pandas.DataFrame.from_csv('myfile.csv', header=1)
print mydf.head(20) # Prints first 20 lines

还有其他一些熊猫选项:

Here's some other pandas options:

pandas.set_option('display.max_columns', 0) # Display any number of columns
pandas.set_option('display.max_rows', 0) # Display any number of rows