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
st.title('E-commerce Orders Visualization')
# Sample data
orders_data = {
'Order ID': [1, 2, 3, 4, 5],
'Product': ['A', 'B', 'C', 'A', 'B'],
'Quantity': [2, 5, 3, 1, 4],
'Price': [20.0, 15.0, 30.0, 20.0, 15.0],
}
orders_df = pd.DataFrame(orders_data)
# Total sales calculation
orders_df['Total Sales'] = orders_df['Quantity'] * orders_df['Price']
st.write('Total Orders:', orders_df.shape[0])
# Display table
st.table(orders_df)
# Bar chart of total sales by product
sales_by_product = orders_df.groupby('Product')['Total Sales'].sum()
plt.figure(figsize=(10, 5))
plt.bar(sales_by_product.index, sales_by_product.values, color='blue')
plt.xlabel('Product')
plt.ylabel('Total Sales')
plt.title('Total Sales by Product')
plt.xticks(rotation=45)
st.pyplot(plt)
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?