joycecast commited on
Commit
e573ff3
ยท
verified ยท
1 Parent(s): 22daeea

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +67 -0
app.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import altair as alt
4
+
5
+ st.set_page_config(page_title="Shipment Monitoring Dashboard", layout="wide")
6
+ st.title("๐Ÿšš Shipment Monitoring Dashboard")
7
+
8
+ uploaded_file = st.file_uploader("Upload your Excel file", type=["xlsx"])
9
+
10
+ if uploaded_file:
11
+ df = pd.read_excel(uploaded_file, sheet_name=0)
12
+
13
+ # Rename columns
14
+ df.columns = ['MAWB', 'MAWB Serial Number', 'Injection Gateway', 'Clearance Port', 'Latest Status',
15
+ 'Cartons', 'Packages', 'Weights', 'Not online packages count', 'ETD', 'ETA', 'ATD', 'ATA',
16
+ 'Last Mile Carrier', 'Readynotice has been notified', 'Vehicle has been arranged',
17
+ 'Pick-upcompletedfrom', 'WH-IN Scan', 'Cargo Ready', 'Ship Out', 'Note',
18
+ 'Exception Note', 'Exception Note Description']
19
+
20
+ # Add status column
21
+ def determine_status(row):
22
+ if pd.isna(row['WH-IN Scan']):
23
+ return "Pending"
24
+ elif pd.isna(row['Cargo Ready']):
25
+ return "WH-IN"
26
+ elif pd.isna(row['Ship Out']):
27
+ return "Cargo Ready"
28
+ else:
29
+ return "Ship Out"
30
+
31
+ df['Shipment Status'] = df.apply(determine_status, axis=1)
32
+
33
+ # Shipment status summary
34
+ st.subheader("๐Ÿ“Š Shipment Status Distribution")
35
+ status_counts = df['Shipment Status'].value_counts().reset_index()
36
+ status_counts.columns = ['Shipment Status', 'Count']
37
+ chart = alt.Chart(status_counts).mark_bar().encode(
38
+ x='Shipment Status',
39
+ y='Count',
40
+ color='Shipment Status',
41
+ tooltip=['Shipment Status', 'Count']
42
+ )
43
+ st.altair_chart(chart, use_container_width=True)
44
+
45
+ # Volume by ETA
46
+ st.subheader("๐Ÿ“… Shipment Volume by ETA")
47
+ df['ETA'] = pd.to_datetime(df['ETA'])
48
+ volume_by_eta = df.groupby('ETA').agg({
49
+ 'MAWB': 'count',
50
+ 'Cartons': 'sum',
51
+ 'Packages': 'sum',
52
+ 'Weights': 'sum'
53
+ }).reset_index().rename(columns={'MAWB': 'Shipment Count'})
54
+
55
+ st.dataframe(volume_by_eta, use_container_width=True)
56
+
57
+ line_chart = alt.Chart(volume_by_eta).transform_fold(
58
+ ['Shipment Count', 'Cartons', 'Packages', 'Weights'],
59
+ as_=['Metric', 'Value']
60
+ ).mark_line(point=True).encode(
61
+ x='ETA:T',
62
+ y='Value:Q',
63
+ color='Metric:N',
64
+ tooltip=['ETA:T', 'Metric:N', 'Value:Q']
65
+ ).properties(height=400)
66
+
67
+ st.altair_chart(line_chart, use_container_width=True)