Haleshot
Haleshot3w ago

Pagination size (custom range set)

CC: @tripleshot "does anyone know how to adjust the pagination size when working with pandas dataframes? it's stuck at 10 rows per page. I tried pd.set_option("display.min_rows", 20) but doesn't do anything and I can't find any docs"; message link - https://discord.com/channels/1059888774789730424/1179936876103225354/1303649800654159965
7 Replies
Haleshot
HaleshotOP3w ago
Using mo.ui.table can help in this regard. Sample code:
df = pd.read_csv("<dataset-path>")

table = mo.ui.table(
data=df,
pagination=True, # Enable pagination
page_size=4, # Set the number of rows per page
label="Label name"
)
table
df = pd.read_csv("<dataset-path>")

table = mo.ui.table(
data=df,
pagination=True, # Enable pagination
page_size=4, # Set the number of rows per page
label="Label name"
)
table
Relevant marimo documentation - mo.ui.table
tripleshot
tripleshot3w ago
thanks @Haleshot but may I ask why the need for workaround since in Jupyter notebook this can be adjusted using standard pandas config. It seems like added complication every time you want to view a df for what should be a config. What am I missing? why is 10 rows a hardcoded config
Myles Scolnick
@tripleshot we default rendering rich dataframes using our table, since it supports pagination, filtering, sorting, etc. we found 10 to be a good default because of these navigation features (pagination, filtering, sorting). 1. you can however turn off "rich dataframes" in your User Configuration in the editor UI (let me know if you can't find this setting) 2. if you want to revert to the plain html ui without a rich datatable, you can use mo.plain
import marimo as mo
mo.plain(df) # This renders pandas as its plain html
import marimo as mo
mo.plain(df) # This renders pandas as its plain html
3. for the above, you don't need to include all the configuration, you can instead do
mo.ui.table(df, page_size=40)
mo.ui.table(df, page_size=40)
tripleshot
tripleshot3w ago
thank you for the great answer. Lots of options in there to choose from and the last one is short enough to be relatively pain free. Would be great to see this configurable in future though!
Myles Scolnick
@tripleshot, would you want to configure the default dataframe size but still using the rich tables? and this configuratoin to apply to ALL tables? and on a per notebook basis? or as your own user? (just want to clarify to log the feature request)
tripleshot
tripleshot3w ago
per notebook basis. So my current use-case is I am doing exploration work on a small df of 34 rows. I need to filter and twist it in different ways. if I can just df[....] at the end of a cell with all the "query" logic that's way more intuitive for me than to have to wrap it inside some other code. I think the pandas set_option mechanism works really well tbh and you can choose when/how to use it. It would just be nice if that got respected since that's how people use it? it's what I tried first by the way (coming from prior knowledge of pandas and notebooks)
Myles Scolnick
got it, your use-case makes sense. thanks for elaborating