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 matplotlib.pyplot as plt
# Sample data of e-commerce orders
data = {
'Order ID': [1, 2, 3, 4, 5],
'Product': ['Laptop', 'Tablet', 'Smartphone', 'Headphones', 'Camera'],
'Quantity': [1, 2, 1, 4, 3],
'Price': [1000, 300, 500, 150, 400],
'Date': [
'2023-01-01', '2023-01-02', '2023-01-05', '2023-01-07', '2023-01-09']
}
# Create a DataFrame
df = pd.DataFrame(data)
df['Total'] = df['Quantity'] * df['Price']
st.title('E-commerce Orders Visualization')
# Display orders table
st.subheader('Orders Table')
st.table(df)
# Visualize total sales per product
total_sales = df.groupby('Product')['Total'].sum()
plt.figure(figsize=(10, 5))
plt.bar(total_sales.index, total_sales.values, color='skyblue')
plt.title('Total Sales per Product')
plt.xlabel('Product')
plt.ylabel('Total Sales ($)')
plt.xticks(rotation=45)
st.subheader('Total Sales Visualization')
st.pyplot(plt)
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?