[英]Pandas DataFrame does not display correctly in Jupyter Notebook
I want to read one csv file into Jupyter Notebook with Python's Pandas lib.我想使用 Python 的 Pandas 库将一个 csv 文件读入 Jupyter Notebook。 I have uploaded .csv file into jupyter notebook, and I wrote a code, but I think that my dataframe does not display correctly.我已将 .csv 文件上传到 jupyter notebook,并编写了代码,但我认为我的数据框无法正确显示。 This is the code for reading the file:这是读取文件的代码:
df = pd.read_csv('text analysis.csv')
print(df)
And my output, when I print that dataframe looks like this:当我打印该数据框时,我的输出如下所示:
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
I have seen much better representation on JN, with all cells.我在 JN 上看到了更好的表示,包括所有单元格。 This looks worse then when I print dataframe in idle当我在空闲时打印数据帧时,这看起来更糟
尝试使用display()插入print()并检查它。
Use this to your code.将此用于您的代码。
pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)
pd.set_option('display.max_colwidth', -1)
This sets it to dispay the entire dataframe.这将其设置为显示整个数据帧。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.