简体   繁体   English

Pandas Dataframe 显示缺失的网格线(Jupyter Notebook)

[英]Pandas Dataframe Display missing gridlines (Jupyter Notebook)

For some reason, whenever I create a dataframe in pandas from reading in data from a file, I don't have gridlines:出于某种原因,每当我通过从文件中读取数据在 Pandas 中创建数据框时,我都没有网格线:

my_dataframe_display

I have checked my settings for pd.options for all display attributes and everything was set to the default.我已经检查了所有显示属性的 pd.options 设置,并且所有内容都设置为默认值。 Can anyone help me change the formatting of my dataframe?谁能帮我更改数据框的格式? This format happens even when I open new python notebooks within jupyter notebook.即使我在 jupyter notebook 中打开新的 python notebook,也会发生这种格式。

Add this and run from a cell添加这个并从一个单元格运行

%%HTML
<style type="text/css">
table.dataframe td, table.dataframe th {
    border: 1px  black solid !important;
  color: black !important;
}

Use df instead of print(df)使用df代替print(df)

Source: answer by MEdwin here Python Jupyter Notebook print dataframe borders资料来源: MEdwin在此处回答Python Jupyter Notebook 打印数据框边框

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

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