Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorting by column with mo.ui.table and mo.ui.dataframe does not include index #1689

Closed
MaWeffm opened this issue Jun 28, 2024 · 0 comments · Fixed by #1691
Closed

Sorting by column with mo.ui.table and mo.ui.dataframe does not include index #1689

MaWeffm opened this issue Jun 28, 2024 · 0 comments · Fixed by #1691
Assignees
Labels
bug Something isn't working

Comments

@MaWeffm
Copy link

MaWeffm commented Jun 28, 2024

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':
image

Sort 'col2':
image

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants