Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python/Pandas-在使用';描述';_Python_File Io_Pandas - Fatal编程技术网

Python/Pandas-在使用';描述';

Python/Pandas-在使用';描述';,python,file-io,pandas,Python,File Io,Pandas,我在iPython笔记本中打开了一个包含许多功能的文件(~145k个观察值,~2000个功能)。当使用df.descripe时,输出使用省略号来总结特征。如何将所有行的描述输出到文件 [In] url = "some large file" df = pd.read_csv(url) df.describe() [Out] Col 1 Col 2 Col 3 Col 4 ... Col 1998 Col 1999 Col 2000 mean B

我在iPython笔记本中打开了一个包含许多功能的文件(~145k个观察值,~2000个功能)。当使用df.descripe时,输出使用省略号来总结特征。如何将所有行的描述输出到文件

[In]
url = "some large file"
df = pd.read_csv(url)
df.describe()

[Out]
       Col 1    Col 2    Col 3    Col 4   ...  Col 1998   Col 1999   Col 2000
mean   Blah     Blah     Blah     Blah    ...  Blah       Blah       Blah
std
min 
etc
我想我可以通过将输出写入文件来避免省略号:

[In]
url1 = "Some output file"
f = open(url1, 'w')
f.write(str(df.describe()))
f.close()

但该文件看起来与输出相同

pd.options.display.max\u columns=2000

如果您不想永久更改笔记本(例如,为了避免在其他单元格中输出过多),您也可以使用
pd.option\u context

with pd.option_context('display.max_columns', 2000):
     print(df.describe())

您是否尝试在iPython笔记本之外以脚本的形式运行此脚本?笔记本可能是这里的罪魁祸首。@Incognos No.…如果可能的话,我想在笔记本中解决这个问题,因为我更喜欢在这个框架内进行初始工作。@GPB这很好,但Incognos的建议是在iPython笔记本之外进行尝试,以确定笔记本是否是您看到的行为的原因。@GPB我知道笔记本和大多数python交互式解释器都会使用省略号来管理显示。给它一个机会来消除不
df.descripe().到_csv(文件路径)
的可能性就行了吗?我不知道为什么这没有更多的投票权。非常有用的提示。谢谢Randy!!!