Hi, I am wondering if there is a way by which i can get the month selection calendar in streamlit, where instead of date, user will be able to select the month and the year.
Hi, I found this code that could be useful:
import streamlit as st
from calendar import month_abbr
from datetime import datetime
with st.expander('Report month'):
this_year = datetime.now().year
this_month = datetime.now().month
report_year = st.selectbox("", range(this_year, this_year - 2, -1))
month_abbr = month_abbr[1:]
report_month_str = st.radio("", month_abbr, index=this_month - 1, horizontal=True)
report_month = month_abbr.index(report_month_str) + 1
# Result
st.text(f'{report_year} {report_month_str}')
Source: Support choosing an entire month in date picker · Issue #2463 · streamlit/streamlit · GitHub
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.