When displaying a pandas dataframe with mo.ui.table or mo.ui.dataframe, the sort function sorts all data columns but not the index. The expected behavior is that sorting a column also changes the order of the index values to maintain the relation between index and the values for each row (or am I missing something here?).
Describe the bug
When displaying a pandas dataframe with mo.ui.table or mo.ui.dataframe, the sort function sorts all data columns but not the index. The expected behavior is that sorting a column also changes the order of the index values to maintain the relation between index and the values for each row (or am I missing something here?).
Sort 'col1':
Sort 'col2':
Environment
{ "marimo": "0.6.23", "OS": "Linux", "OS Version": "6.5.0-42-generic", "Processor": "x86_64", "Python Version": "3.11.6", "Binaries": { "Browser": "--", "Node": "--" }, "Requirements": { "click": "8.1.7", "importlib-resources": "missing", "jedi": "0.19.1", "markdown": "3.5.1", "pymdown-extensions": "10.5", "pygments": "2.17.2", "tomlkit": "0.12.3", "uvicorn": "0.25.0", "starlette": "0.34.0", "websockets": "12.0", "typing-extensions": "4.9.0", "black": "23.12.1" } }
Code to reproduce
import marimo as mo import pandas as pd
d = {'col3': range(4), 'col1': [0, 1, 2, 3], 'col2': [6, 5, 4, 3]}
df = pd.DataFrame(data=d, index=[0, 1, 2, 3]) df.index.names = ["idx"]
mo.ui.dataframe(df)
mo.ui.table(df)