st.data_editor column order not respected when column name type is not str
Checklist
- [X] I have searched the existing issues for similar issues.
- [X] I added a very descriptive title to this issue.
- [X] I have provided sufficient information below to help reproduce this issue.
Summary
I want to make an editable dataframe using st.data_editor. My dataframe has int column names, in descending order. For my application, it is important that this order is respected.
However, when I define the column_config argument, the order gets flipped into ascending order.
I have also tried specifying column_order, but this results in an error TypeError: bad argument type for built-in operation (this is because the column names are not str type but they are expected as such)
df = st.data_editor(
df,
column_order=df.columns,
column_config={
col: st.column_config.TextColumn(
col,
)
for col in df.columns
},
)
Reproducible Code Example
import pandas as pd
import streamlit as st
df = pd.DataFrame(
[
["A", "B", "C"],
["D", "E", "F"],
["G", "H", "I"],
],
columns=range(3, 0, -1)
df = st.data_editor(
df,
column_config={
col: st.column_config.TextColumn(
col,
)
for col in df.columns
},
)
Steps To Reproduce
Run the above code and see the column order be incorrect
Expected Behavior
Current Behavior
Is this a regression?
- [ ] Yes, this used to work in a previous version.
Debug info
- Streamlit version: 1.33.0
- Python version: 3.12
- Operating System: Mac OS X
- Browser: Firefox
Additional Information
No response
If this issue affects you, please react with a 👍 (thumbs up emoji) to the initial post.
Your feedback helps us prioritize which bugs to investigate and address first.
@timotk Thanks for reporting this issue 👍 I was able to reproduce this here. Non-string column names aren't super well supported right now, but I think it wouldn't be to complicated to fix this.
I would like to work on this. Can I get assigned to this issue?
Could I get assigned to this please?