Skip to content

add class=„pandas-empty“ to NaN-cells’ HTML #7338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add class=„pandas-empty“ to NaN-cells’ HTML
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.
  • Loading branch information
hmeine committed Jun 4, 2014
commit 0fb6ed93786f524a1f07cc89a036d15dd259b1e2
2 changes: 2 additions & 0 deletions pandas/core/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down