Create an app to visualize e-commerce orders
To upload files, please first save the app
import streamlit as st
import pandas as pd
import altair as alt
@st.cache_data
def fetch_orders():
# Simulated e-commerce orders data
data = {
'OrderID': range(1, 101),
'Customer': [f'Customer {i}' for i in range(1, 101)],
'TotalAmount': pd.np.random.uniform(10, 500, size=100),
'OrderDate': pd.date_range(start='2022-01-01', periods=100)
}
return pd.DataFrame(data)
st.title('E-commerce Orders Visualization')
# Fetch data
orders_df = fetch_orders()
st.header('Order Data')
st.write(orders_df)
st.header('Total Orders Over Time')
order_over_time = orders_df.groupby(orders_df['OrderDate'].dt.date).sum().reset_index()
chart = alt.Chart(order_over_time).mark_line().encode(
x='OrderDate:T',
y='TotalAmount:Q'
).properties(title='Total Amount of Orders Over Time')
st.altair_chart(chart, use_container_width=True)
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?