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
st.title('E-commerce Orders Visualizer')
# Sample order data
num_orders = 100
np.random.seed(42)
order_data = {
'Order ID': np.arange(1, num_orders + 1),
'Customer Name': [f'Customer {i}' for i in range(1, num_orders + 1)],
'Product': np.random.choice(['Product A', 'Product B', 'Product C'], num_orders),
'Quantity': np.random.randint(1, 5, num_orders),
'Total Price': np.round(np.random.uniform(10.0, 100.0, num_orders), 2),
'Order Date': pd.date_range(start='2023-01-01', periods=num_orders, freq='D')
}
orders_df = pd.DataFrame(order_data)
st.subheader('Orders Data')
st.dataframe(orders_df)
# Visualization
st.subheader('Total Revenue by Product')
revenue_by_product = orders_df.groupby('Product')['Total Price'].sum().reset_index()
st.bar_chart(revenue_by_product.set_index('Product'))
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?