繁体   English   中英

Pandas DataFrame 在 Jupyter Notebook 中无法正确显示

[英]Pandas DataFrame does not display correctly in Jupyter Notebook

我想使用 Python 的 Pandas 库将一个 csv 文件读入 Jupyter Notebook。 我已将 .csv 文件上传到 jupyter notebook,并编写了代码,但我认为我的数据框无法正确显示。 这是读取文件的代码:

df = pd.read_csv('text analysis.csv')
print(df)

当我打印该数据框时,我的输出如下所示:

       avg title word len.  avg text word len.  avg sent. len.  \
0                     5.20                4.27           11.00   
1                     4.69                4.98           26.20   
2                     5.50                4.53           21.62   
3                     4.82                4.42           15.10   
4                     6.40                5.07           36.50   
...                    ...                 ...             ...   
34205                 4.29                4.96           24.60   
34206                 4.67                4.58           13.00   
34207                 4.92                5.08           26.79   
34208                 4.09                4.72           22.23   
34209                 4.75                5.76           18.38 

我在 JN 上看到了更好的表示,包括所有单元格。 当我在空闲时打印数据帧时,这看起来更糟

尝试使用display()插入print()并检查它。

将此用于您的代码。

pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)
pd.set_option('display.max_colwidth', -1)

这将其设置为显示整个数据帧。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM