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 numpy as np
import matplotlib.pyplot as plt
st.title('E-Commerce Orders Visualization')
# Simulating e-commerce order data
np.random.seed(42)
num_orders = 100
orders = pd.DataFrame({
'Order ID': range(1, num_orders + 1),
'Product': np.random.choice(['Product A', 'Product B', 'Product C'], num_orders),
'Quantity': np.random.randint(1, 10, num_orders),
'Price': np.random.uniform(10, 100, num_orders)
})
orders['Total'] = orders['Quantity'] * orders['Price']
st.header('Order Data')
st.write(orders)
# Visualizing total sales by product
sales_by_product = orders.groupby('Product')['Total'].sum().reset_index()
st.header('Total Sales by Product')
fig, ax = plt.subplots()
ax.bar(sales_by_product['Product'], sales_by_product['Total'], color='skyblue')
ax.set_xlabel('Product')
ax.set_ylabel('Total Sales')
ax.set_title('Total Sales by Product')
st.pyplot(fig)
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?