相当于R's View for Python's pandas [英] equivalent of R's View for Python's pandas
问题描述
View
是一项非常有用的功能,可让我查看R中大型数据框的横截面.
The View
is a very useful function to allow me to see cross-section of large data frames in R.
对于Python的熊猫DataFrame
,R的View
函数是否等效?
Is there any equivalent of R's View
function for Python's pandas DataFrame
?
对于R,我使用RStudio
,对于Python使用PyCharm
.
I use RStudio
for R and PyCharm
for Python.
推荐答案
一个更快的选择可能是设置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
这篇关于相当于R's View for Python's pandas的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!