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
def load_data():
# Load your e-commerce order data here
# For demonstration, let's create a sample DataFrame
data = {
'Order ID': [1, 2, 3, 4, 5],
'Product': ['A', 'B', 'C', 'D', 'E'],
'Quantity': [10, 20, 15, 5, 12],
'Price': [100, 200, 150, 50, 120],
'Date': pd.to_datetime(['2023-01-01', '2023-01-05', '2023-01-10', '2023-01-15', '2023-01-20'])
}
return pd.DataFrame(data)
df = load_data()
st.title('E-commerce Orders Visualization')
# Display the DataFrame
st.subheader('Order Data')
st.dataframe(df)
# Create a chart
st.subheader('Sales Overview')
chart_data = df.groupby('Product').agg({'Quantity': 'sum', 'Price': 'sum'}).reset_index()
chart = alt.Chart(chart_data).mark_bar().encode(
x='Product:N',
y='sum(Price):Q',
tooltip=['Product', 'sum(Quantity):Q', 'sum(Price):Q']
).interactive()
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?