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 data here
return pd.DataFrame({
'Order ID': [1, 2, 3, 4],
'Product': ['A', 'B', 'A', 'C'],
'Quantity': [1, 2, 1, 1],
'Price': [100, 150, 100, 200],
'Date': pd.to_datetime(['2023-01-01', '2023-01-02', '2023-01-01', '2023-01-03'])
})
df = load_data()
st.title('E-commerce Orders Visualization')
# Display data as a table
st.subheader('Orders Data')
st.dataframe(df)
# Bar chart of total sales per product
st.subheader('Total Sales per Product')
bar_chart = alt.Chart(df).mark_bar().encode(
x='Product:N',
y='sum(Quantity * Price):Q',
tooltip=['Product:N', 'sum(Quantity * Price):Q']
).properties(title='Total Sales by Product')
st.altair_chart(bar_chart, use_container_width=True)
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?