To upload files, please first save the app
import streamlit as st
import pandas as pd
# Sample dataframes
subscribers_df = pd.DataFrame({
'date': pd.date_range(start='2023-01-01', periods=10, freq='D'),
'count': [100, 150, 200, 250, 300, 350, 400, 450, 500, 550]
})
events_df = pd.DataFrame({
'date': pd.to_datetime(['2023-01-03', '2023-01-06', '2023-01-09']),
'event': ['Event 1', 'Event 2', 'Event 3']
})
# Prepare the ECharts options
option = {
'tooltip': {
'trigger': 'axis'
},
'legend': {
'data': ['Subscribers', 'Events']
},
'xAxis': [{
'type': 'category',
'data': subscribers_df['date'].astype(str).tolist(),
'boundaryGap': False
}],
'yAxis': [{
'type': 'value'
}],
'series': [{
'name': 'Subscribers',
'type': 'line',
'data': subscribers_df['count'].tolist(),
'markPoint': {
'data': [
{'name': event['event'], 'coord': [event['date'].date().strftime('%Y-%m-%d'), 0], 'value': event['date'].date().strftime('%Y-%m-%d')}
for event in events_df.to_dict('records')
]
}
}]
}
# Render the ECharts graph in Streamlit
st_echarts(option=option, height="400px")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?