Pandas Dataframe display in the client side

Hello!

I have the code on the server side that returns a pandas dataframe.

I am trying to display it in a table format on the client side - but can’t understand how to do it.

I cant send pandas dataframes to client, and dont really understand what object I should transform it to. So I can display it as a table.

Thanks!

Clone link:
https://anvil.works/build#app:LCW35LQZ5LZ7WXO4

1 Like

Welcome to the forum!

I can’t really comment at the moment, because you just linked to the app itself rather than a clone link. See documentation here:

Simplest is to use pandas to_markdown function, which returns a string that can be passed to the client and directly assigned to the content property of the rich_text component.

It looks like your clone link is dead but it’s pretty straightforward from there…

# client side
self.rich_text.content = anvil.server.call('df_as_markdown')

# server side
@anvil.server.callable
def df_as_markdown():
    # get the df somehow
    return df.to_markdown()
3 Likes