Python/Pandas&Numpy

dataframe ๊พธ๋ฏธ๊ธฐ

metamong 2023. 1. 22.

๐Ÿคฒ pandas์˜ dataframe์„ jupyter css ํŒŒ์ผ ์ฝ”๋“œ๋ฅผ ๊ณ ์น˜๊ฑฐ๋‚˜ ์ถ”๊ฐ€ํ•˜๋ฉด ์ž…๋ง›์— ๋งž๊ฒŒ ๊พธ๋ฐ€ ์ˆ˜ ์žˆ๋‹ค! ๊ทธ ๊ณผ์ •์„ ์†Œ๊ฐœํ•ด๋ด„

 

- ์ˆ˜์ • ํ›„ -

 

๐Ÿคฒ jupyter notebook styling css ํŒŒ์ผ ์ด 2๊ฐœ๋ฅผ ์ˆ˜์ •ํ–ˆ๋‹ค.

โ‘  custom.css

โ‘ก style.min.css

๐Ÿคฒ custom.css

 

๐Ÿคฒ ์„ค๋ช…์— ์˜ํ•˜๋ฉด overriding๋˜๋Š” ๋™์ผ๊ตฌ์กฐ code์˜ ์ตœ์ข… of ์ตœ์ข…๋ณธ์„ ์„ ์–ธํ•  ๋•Œ ์“ฐ๋ผ๋Š” ์•ˆ๋‚ด๋ฌธ

 

๐Ÿคฒ .dataframe์€ style.min์—์„œ ์ฐพ์•„๋„ ์—†์–ด์„œ(ctrl+F5 ๋‹จ์ถ•ํ‚ค) custom.css์— ๊น”๋”ํžˆ ์ผ๋‹ค.

.dataframe th{
    background:#B7E0F0; 
    font-weight: 600;
    border:3px solid white; 
}

 

<th> tag๋Š” dataframe table์˜ ์ œ๋ชฉ์— ํ•ด๋‹นํ•˜๋Š” cell๋กœ, ์ƒ‰๊น”์„ ์ž…ํžˆ๊ณ , 3px solid white cell ๊ฐ„ ๊ฒฝ๊ณ„๋ฅผ ์„ค์ •. font-weight๋ฅผ ๋ถ€๊ณผํ•ด ์ข€ ๋” ๊ฐ•์กฐ

๐Ÿคฒ style.min.css

.rendered_html tr,
.rendered_html th,
.rendered_html td {
  text-align: right;
  vertical-align: middle;
  padding: 0.5em 0.5em;
  line-height: normal;
  white-space: normal;
  max-width: none;
  border: 1px black solid !important;
}

 

div#notebook_panel {
  margin: 0px;
  padding: 0px;
  box-sizing: border-box;
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  height: 100%;
  background-color: #33E9FF;
}

 

<td> tag๋Š” dataframe์—์„œ ํ•˜๋‚˜์˜ cell์„ ์˜๋ฏธํ•˜๋ฉฐ, ๊ฐ cell์˜ border color, width ์„ค์ •. ํ˜น์‹œ ๊ฒน์น ๊นŒ๋ด !important ์šฐ์„ ์ˆœ์œ„

→ #notebook panel์—์„œ bgcolor ์„ค์ •

→ ๊ทธ ์™ธ์—๋„ code cell border & ์ƒ‰๊น” ์„ค์ •ํ•จ


* ์ฐธ๊ณ  ์ถœ์ฒ˜) https://datadoctorblog.com/2020/11/14/Py-Jupyter-Notebook-Styling-02/

 

๋Œ“๊ธ€