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
# Sample data to simulate e-commerce orders
data = {
'Order ID': [1, 2, 3, 4, 5],
'Product': ['Widget A', 'Widget B', 'Widget A', 'Widget C', 'Widget B'],
'Quantity': [4, 2, 5, 3, 7],
'Price': [20.00, 30.00, 20.00, 50.00, 30.00],
'Total': [80.00, 60.00, 100.00, 150.00, 210.00]
}
orders_df = pd.DataFrame(data)
st.title('E-commerce Orders Visualization')
# Displaying the data in a table
st.subheader('Orders Data')
st.table(orders_df)
# Bar chart for total revenue per product
revenue_chart = alt.Chart(orders_df).mark_bar().encode(
x='Product:N',
y='sum(Total):Q',
color='Product:N'
).properties(
title='Total Revenue by Product'
)
st.subheader('Total Revenue by Product')
st.altair_chart(revenue_chart, use_container_width=True)
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?