✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
📊 Dash 2.0 is Arriving. Register here.

Dataframe to html table using Dash

Hi,

I’m trying to generate an html table using Table component of dash html package, but I’m getting error loading dependencies error.

Could anyone help me with this ?

I’m doing the below

def generate_table(dataframe, max_rows=10):
return html.Table(
# Header
[html.Tr([html.Th(col) for col in dataframe.columns])] +

    # Body
    [html.Tr([
        html.Td(dataframe.iloc[i][col]) for col in dataframe.columns
    ]) for i in range(min(len(dataframe), max_rows))]
)

html.Div([
generate_table(my_dataframe)
])

Update: - I checkd in my browser and I can see the below error logged in console.

bundle.js:2 Error: component.type is undefined
at i (<html link, i’m not allowed to put more than 2 links here, so can’t post that link>:2 Error: component.type is undefined

Regards,
Prabhakar

Hm, not sure what’s going on here. Have you installed all of the dependencies in https://plot.ly/dash/installation?

Hi Chris ,

Thanks again for your help. Yes I have. For some reason the html.Table
components is not being recognised here. I’m also trying to debug and will
post any updates if I get something relevant.

On the same lines, is it possible to make an interactive table like
allowing the users to select few rows from the table ?

Regards,
Prabhakar

Hi Pray,

I have exactly the same issue as you. Did you manage to resolve this after all?

Regards,

Michael