Hide None in st.dataframe

Is there a way to hide the None words in pandas dataframe without the need to replace the null value with empty string?

My code is:

df = df.style.background_gradient(cmap='Blues', axis=None).

which produces:

If I replaced the null value with empty strings, the above code will not work due to a mixture of datatypes. However, I would like to hide the None in the empty cells. Thank you!

Hey @camole,

Unfortunately, there isn’t a built-in way to automatically hide None via st.dataframe, but this would be a great enhancement request – feel free to post this here so our product and engineering teams can take a look!

Also, I did stumble upon this solution in this thread – not sure if this would work for your specific use case but might be worth giving it a shot

# table.py
import pandas as pd
import streamlit as st

df = pd.read_csv("example.csv", header=0)
df = df.style.highlight_null(props="color: transparent;") 
1 Like

Thank you!