Skip to content
Advertisement

Control how NAs are displayed with pandas styler

I am trying to use the na_rep argument of df.style.format() to control how cells with NaN are shown in the table.

Documentation: https://pandas.pydata.org/docs/reference/api/pandas.io.formats.style.Styler.format.html

Reproducible code:

JavaScript

I get this error message.

TypeError: format() got an unexpected keyword argument ‘na_rep’

Do you know a work around? Tks!

Advertisement

Answer

I ended up using a grey color for the text and the background of NA cells to hide the NAs

JavaScript

This is what it looks like:

enter image description here

Advertisement