From 0fb6ed93786f524a1f07cc89a036d15dd259b1e2 Mon Sep 17 00:00:00 2001 From: Hans Meine Date: Wed, 4 Jun 2014 08:37:53 +0200 Subject: [PATCH] =?UTF-8?q?add=20class=3D=E2=80=9Epandas-empty=E2=80=9C=20?= =?UTF-8?q?to=20NaN-cells=E2=80=99=20HTML?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows to do CSS styling, e.g. using td.pandas-empty { color: #eee } to de-emphasize, or td.pandas-empty { background-color: yellow } to let empty cells stand out. --- pandas/core/format.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandas/core/format.py b/pandas/core/format.py index c2f439877ca00..f344d4b009df9 100644 --- a/pandas/core/format.py +++ b/pandas/core/format.py @@ -711,6 +711,8 @@ def write_th(self, s, indent=0, tags=None): return self._write_cell(s, kind='th', indent=indent, tags=tags) def write_td(self, s, indent=0, tags=None): + if s == self.fmt.na_rep: + tags = (tags or "") + ' class="pandas-empty"' return self._write_cell(s, kind='td', indent=indent, tags=tags) def _write_cell(self, s, kind='td', indent=0, tags=None):