Get help from the marimo community

Updated 3 months ago

Freeze Column Table Argument Not Working as Expected

I'm trying to use the freeze_columns_left argument in mo.ui.table, and I am not getting an error, but the specified column is not frozen. This is my code. Can you tell me why?
Attachment
image.png
e
M
22 comments
I think you forgot to add freeze_columns_left=["Name"] inside the if condition πŸ€”
That is 100% true, I thought I was testing with something that didn't meet the condition but maybe not because I just walked away and came back and it was working πŸ€¦πŸΌβ€β™€οΈ
Is it possible to make the dataframe's index freeze?
You are using polars right?

maybe you can try
Plain Text
mo.ui.table(
    df[mask].with_row_index(),
    show_column_summaries=False,
    selection=None,
    pagination=None,
    freeze_columns_left=["index", "Name"],
)
I think you need to create a new cell and run the code there

Edit in-place doesn't change the pinning, but seems to be fixed in the next release
I was using pandas!
sorry, I saw you were indexing with mask so assumed that you were using polars

then
Plain Text
mo.ui.table(
    df[mask].reset_index(),
    show_column_summaries=False,
    selection=None,
    pagination=None,
    freeze_columns_left=["index", "Name"],
)


should work?
Sorry, I was following a tutorial on how to "mask" a data frame table to only show values selected on a plotly chart! I will probably not get back to this until later today but will try that out.
I didn't get this to work - just to clarify, I'm referring to the dataframe index, not a column called index
Attachment
image.png
for context, I'm trying to get the column called "Number" (which is the dataframe index) to freeze on the left
Attachment
image.png
In this case, just freeze_columns_left=["Number, "Name"] should work?
df.reset_index() should automatically generate a column named "index"
Attachment
Screenshot_2024-09-19_at_21.44.40.png
this is what I get
Attachment
image.png
and this is what I get when I try this
Attachment
image.png
is "Number" in team_df2[mask].columns?
also, you forgot () inside the if condition for reset_index
my bad on reset_index, but fixing that still didn't change the behavior. and no, it is not in team_df2[mask] because it is the dataframe's index
my bad, have limited experience with pandas

the only solution I can come of is setting "Number" to a regular column instead of index
I think freeze_columns_left ignores index column for pandas
is there a way to not display the index in the table then? because if it isn't the index, then it wants to show a serialized/default index column in the table also
maybe
Plain Text
mo.ui.table(
    df[mask].reset_index(),
    show_column_summaries=False,
    selection=None,
    pagination=None,
    freeze_columns_left=["Number", "Name"],
)

this should reset the "Number" index to a regular column
So this is kind of working as I expected..... the thing I am finding weird is that if I put index in the freeze list after using reset_index, it does freeze the auto-assigned index.
Attachment
image.png
for some reason you only cannot assign index in freeze_columns_left when index is defined by a dataframe column, not when the default auto-assigned index is used
Add a reply
Sign up and join the conversation on Discord