Last active
March 9, 2022 01:55
-
-
Save YiLi225/de467072c81643627c010f21fd2fafec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
st.title("Online Retail") | |
## !!! date options | |
date = st.sidebar.selectbox( | |
"Select a Invoice Date Range", | |
[ | |
"'2010-12-01' and '2011-01-01'", | |
"'2010-12-01' and '2010-12-15'" | |
]) | |
## !!! product options | |
product = st.sidebar.selectbox( | |
"Select a Product", | |
[ | |
'CHOCOLATE HOT WATER BOTTLE', | |
'GREY HEART HOT WATER BOTTLE', | |
'JUMBO BAG PINK POLKADOT', | |
'WHITE METAL LANTERN' | |
]) | |
## Take in the query | |
df_series = pd.read_sql(timeSeries_query, engine) | |
df_series['InvoiceDate'] = pd.to_datetime(df_series['InvoiceDate']) | |
## Line chart | |
plt.rc('figure', figsize=(10, 5)) | |
fig, ax = plt.subplots() | |
sns.lineplot(data=df_series, x='InvoiceDate', y='Total_Sale_Amt', hue='Description', style='Description', | |
linewidth=0.8, marker='o') | |
start, end = ax.get_xlim() | |
plt.xticks(ticks=np.arange(start, end, 2), ## 2 days apart | |
rotation=45, ha='right') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment