evan54
November 24, 2024, 1:31pm
1
I’m using st.column_config.DateColumn - Streamlit Docs
It works well when displaying data but if I want to add a new row in data_editor then the format seems to default to the locale, in my case mm/dd/yyyy instead of my preference of YYYY-MM-DD as specified in the format keyword.
Is there a way to do what I’m describing?
Encrypt
November 26, 2024, 1:42pm
2
The format remains “YYYY-MM-DD” even after adding a new row in the data editor.
import streamlit as st
import pandas as pd
# Sample data
data = {
'Date': ['2023-01-01', '2023-02-01', '2023-03-01'],
'Value': [10, 20, 30]
}
df = pd.DataFrame(data)
# Convert the 'Date' column to datetime
df['Date'] = pd.to_datetime(df['Date'])
# Display data editor with date column configuration
edited_df = st.data_editor(
df,
column_config={
'Date': st.column_config.DateColumn(format='YYYY-MM-DD')
},
num_rows='dynamic'
)
system
Closed
May 25, 2025, 1:43pm
3
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.