Announcing Dash Bio 1.0.0 🎉 : a one-stop-shop for bioinformatics and drug development visualizations.

Dash DataTable filling blank cells with null instead of keeping them blank

I have a data frame with lots of blank values that I would like to display in a dash app. I added the ‘presentation’: ‘markdown’ and now all blank cells are filled with nulls. Previously they were displayed as blank.

I cannot share most of my code or the data due to sensitivity. But here is how I create the table

And here is the result. I do not want these cells to display ‘null’ I would like them to remain blank.
image

Is there an efficient way to correct this? Obviously I could loop and add empty strings or something in all blank values. But this will add lots of computation time.
Any suggestions welcome! Thank you for your time!

EDIT: I am reading this data from an xls file type. If I instead use a csv the behavior is what I want. So I believe this issue has more to do with how I read the file rather than the display. Here is my parsing function. I am very new to this so I am not sure if there is another method for decoding that anyone could recommend.

image

Hi @eambrioso

Try changing your column definition to include `“type”: “text”


table_cols=[{"name": i, "id": i, "presentation":"markdown", "type": "text"} for i in df.columns]
   


Thank you for your response. Sadly this did not work. The values remain as null.

HI @eambrioso

Hmm. Could you please try running this example.:

from dash import Dash, dash_table
import pandas as pd

df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/solar.csv')

app = Dash(__name__)

app.layout = dash_table.DataTable(
    id='table',
    columns=[{"name": i, "id": i, "presentation":"markdown", "type": "text"} for i in df.columns],
    data=df.to_dict('records'),
    editable=True
)

if __name__ == '__main__':
    app.run_server(debug=True)

If you delete data it looks correct -with blank cells:
image

And without the "type": "text" added, the deleted cells show “null” :

image


Do you get the same results? Can you share a minimal example with non-confidential code and toy data that reproduces your issue?

It works fine with a csv the problem is in how I ingest xml files. I made an edit to the original post to show how I read the file into a dataframe.