marimo
marimo copied to clipboard
[data editor] remove row limit on mo.ui.data_editor
Description
mo.ui.data_editorhas a maximum of 1000 rows:
ValueError: Data editor supports a maximum of 1000 rows
-
most dataframes have far more rows than that
-
removing the max rows would make this element much more useful
(@delennc)
Suggested solution
No maximum on dataframe rows; table loaded via RPCs to backend, similar to ui.table?
Alternative
No response
Additional context
No response
Further context from @delennc:
"I'd like to turn any of my dataframes editable to add annotation columns", with limits being fundamentally difficult to work with. Limits also make it unwieldy to write back to your original dataframe, since they require custom joining logic back to the main dataframe.
I am curious what Streamlit uses for their implementation of their data_editor . Here are some things I noticed:
- No row limit, I tried a dataframe with 1 million rows, no problem.
- Fast (infinite scroll)
- Same renderer for
data_editorand regular dataframes
Of course, while streamlit is just for apps, this could be useful when notebook-ing as well.
Streamlit code:
import streamlit as st
import pandas as pd
cmds = [
{"command": "st.time_input", "rating": rating, "is_widget": True}
for rating in range(1_000_000)
]
st.write("Data editor")
df = pd.DataFrame(
[
{"command": "st.selectbox", "rating": 4, "is_widget": True},
{"command": "st.balloons", "rating": 5, "is_widget": False},
{"command": "st.time_input", "rating": 3, "is_widget": True},
*cmds,
]
)
edited_df = st.data_editor(df)
st.write("Raw dataframe output, value of data editor")
st.write(edited_df)
favorite_command = edited_df.loc[edited_df["rating"].idxmax()]["command"]
st.markdown(f"Your favorite command is **{favorite_command}** 🎈")