Skip to content

Displaying a list of dictionaries from a FastAPI endpoint #1159

Answered by fsmosca
yttcs asked this question in Question
Discussion options

You must be logged in to vote

One way is convert that list of dict to a pandas dataframe then dataframe to reactpy vdom using html_to_vdom function.

In one of my reactpy explorations blog, I created a component that converts a dataframe to a vdom.

Dataframe to VDOM

@component
def DataframeToVdom(df):
    """Converts a pandas dataframe into ReactPy VDOM."""
    height = 400
    html_rec = df.to_html(
        index=False,
        border=0,
        justify='center',
        classes=['table', 'text-nowrap', 'table-bordered',
                 'text-center', 'table-striped', 'table-hover',
                 'table-primary']
    )
    return html.div(
        html.style(f"""
        .table-fix-head {{
            overflow-y: …

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by Archmonger
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy