Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -46,16 +46,13 @@ with tabs[0]:
|
|
| 46 |
start_date, end_date = st.date_input("Select ETA date range:", [min_date, max_date], min_value=min_date, max_value=max_date)
|
| 47 |
df = df[(df['ETA'] >= pd.to_datetime(start_date)) & (df['ETA'] <= pd.to_datetime(end_date))]
|
| 48 |
|
| 49 |
-
# Shipment status
|
| 50 |
st.subheader("Shipment Status Distribution")
|
| 51 |
status_order = ["Pending", "WH-IN", "Cargo Ready", "Ship Out"]
|
| 52 |
status_counts = df['Shipment Status'].value_counts().reindex(status_order).reset_index()
|
| 53 |
status_counts.columns = ['Shipment Status', 'Count']
|
| 54 |
status_counts = status_counts.dropna()
|
| 55 |
|
| 56 |
-
# Altair-based radio-like selector
|
| 57 |
-
selected_status = st.radio("Select a Shipment Status to filter the details below:", options=status_order, index=0)
|
| 58 |
-
|
| 59 |
chart = alt.Chart(status_counts).mark_bar().encode(
|
| 60 |
x=alt.X('Shipment Status', sort=status_order),
|
| 61 |
y='Count',
|
|
@@ -82,9 +79,16 @@ with tabs[0]:
|
|
| 82 |
|
| 83 |
st.altair_chart(line_chart, use_container_width=True)
|
| 84 |
|
| 85 |
-
#
|
| 86 |
st.subheader("Shipment Detail View by ETA")
|
| 87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
sorted_df = filtered_df[['MAWB', 'ETA', 'ATA', 'Shipment Status', 'Cartons', 'Last Mile Carrier']].sort_values(by='ETA')
|
| 89 |
st.dataframe(sorted_df, use_container_width=True)
|
| 90 |
|
|
@@ -98,6 +102,6 @@ with tabs[1]:
|
|
| 98 |
# Try to match the correct column
|
| 99 |
last_mile_col = [col for col in df_ctn.columns if "last mile" in col.lower()][0]
|
| 100 |
|
| 101 |
-
# Group by Last Mile Service and count
|
| 102 |
-
grouped = df_ctn.groupby(last_mile_col).
|
| 103 |
st.dataframe(grouped, use_container_width=True)
|
|
|
|
| 46 |
start_date, end_date = st.date_input("Select ETA date range:", [min_date, max_date], min_value=min_date, max_value=max_date)
|
| 47 |
df = df[(df['ETA'] >= pd.to_datetime(start_date)) & (df['ETA'] <= pd.to_datetime(end_date))]
|
| 48 |
|
| 49 |
+
# Shipment status distribution
|
| 50 |
st.subheader("Shipment Status Distribution")
|
| 51 |
status_order = ["Pending", "WH-IN", "Cargo Ready", "Ship Out"]
|
| 52 |
status_counts = df['Shipment Status'].value_counts().reindex(status_order).reset_index()
|
| 53 |
status_counts.columns = ['Shipment Status', 'Count']
|
| 54 |
status_counts = status_counts.dropna()
|
| 55 |
|
|
|
|
|
|
|
|
|
|
| 56 |
chart = alt.Chart(status_counts).mark_bar().encode(
|
| 57 |
x=alt.X('Shipment Status', sort=status_order),
|
| 58 |
y='Count',
|
|
|
|
| 79 |
|
| 80 |
st.altair_chart(line_chart, use_container_width=True)
|
| 81 |
|
| 82 |
+
# Status filter before detail view
|
| 83 |
st.subheader("Shipment Detail View by ETA")
|
| 84 |
+
status_options = ["All"] + status_order
|
| 85 |
+
selected_status = st.radio("Select a Shipment Status to filter the details below:", options=status_options, index=0)
|
| 86 |
+
|
| 87 |
+
if selected_status == "All":
|
| 88 |
+
filtered_df = df.copy()
|
| 89 |
+
else:
|
| 90 |
+
filtered_df = df[df['Shipment Status'] == selected_status]
|
| 91 |
+
|
| 92 |
sorted_df = filtered_df[['MAWB', 'ETA', 'ATA', 'Shipment Status', 'Cartons', 'Last Mile Carrier']].sort_values(by='ETA')
|
| 93 |
st.dataframe(sorted_df, use_container_width=True)
|
| 94 |
|
|
|
|
| 102 |
# Try to match the correct column
|
| 103 |
last_mile_col = [col for col in df_ctn.columns if "last mile" in col.lower()][0]
|
| 104 |
|
| 105 |
+
# Group by Last Mile Service and aggregate by row count
|
| 106 |
+
grouped = df_ctn.groupby(last_mile_col).size().reset_index(name='CTN Count')
|
| 107 |
st.dataframe(grouped, use_container_width=True)
|