Get help from the marimo community

Updated 4 months ago

How to get a value from selected row on a table?

At a glance

The community member has an existing table with "single" selection enabled. When a row is selected, the filtered_data variable is assigned the result of mo.ui.table(result, selection="single", show_column_summaries=False). The community member wants to get the partid of the selected row, but doesn't know the index number of that row in advance.

A comment from another community member suggests that the solution is to use filtered_data.value['partid'].values[0] to get the partid of the selected row.

I have an exisitng table with "single" selection enabled. When I select a row,

Plain Text
filtered_data := mo.ui.table(result, selection="single", show_column_summaries=False)
print(filtered_data.value)
    partid    year  price
1  60441-1    2024  31.99
1  60441-1
print(filtered_data.value['partid'])
1  60441-1
print(filtered_data.value['partid'][1])
60441-1

How do I get the partid of the selected row? I don't know in advance what index number of that row is?
B
1 comment
i solved with
Plain Text
filtered_data.value['partid'].values[0]
Add a reply
Sign up and join the conversation on Discord