Get help from the marimo community

Updated 2 months ago

display output of all expressions in a single cell

At a glance

The community member is having an issue with the Marimo library, where they can't get it to display multiple dataframes in a single cell by default. The default behavior in Jupyter is to only display the output of the last evaluated expression in a cell. The community member has found a workaround for Jupyter by running a script to display the output of all expressions, but they are wondering if there is a simpler way to achieve the same result in Marimo.

In the comments, another community member suggests that there is no automatic way to output all expressions, and the current idea of using mo.output.append is probably the best option available today.

Likely Issue
Can't get marimo to display multiple dataframes in a single cell by default.

Context:
  • By default, jupyter prints only the output of the last evaluated expression in a single cell. Working with multiple data frames, its tiresome to only look at a single frame in one cell.
  • Known work around for jupyter: if you run the following script in cell, it starts displaying output of all the expressions.
Plain Text
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"


Details
For the following sample code:
Plain Text
df1=pd.DataFrame([[1,2],[3,4]],columns=['col1','col2'])
df2=pd.DataFrame([[5,6],[7,8]],columns=['col3','col4'])
df1.sample(2)
df2.sample(2)

My expectation is that marimo renders 2 frames, one below another if I execute the same property update..

alternatively, I can achieve the same(render 2 dataframe in same cell) by using the output api.
Plain Text
mo.output.append(df1.sample(2))
mo.output.append(df2.sample(2))

I was wondering if there is a simpler way to do this for all expressions in a cell.

Apologies if I am missing something obvious.
M
u
2 comments
We don’t have a way to automatically output all expressions. You current idea of mo.output.append is probably the best option today
Add a reply
Sign up and join the conversation on Discord