Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -116,7 +116,8 @@ with tabs[0]:
|
|
| 116 |
|
| 117 |
with tabs[1]:
|
| 118 |
st.header("Upload CTN File for Last Mile Summary")
|
| 119 |
-
ctn_files = st.file_uploader("Upload one or more Excel files with Last Mile Service",
|
|
|
|
| 120 |
|
| 121 |
if ctn_files:
|
| 122 |
df_list = []
|
|
@@ -126,23 +127,18 @@ with tabs[1]:
|
|
| 126 |
|
| 127 |
df_ctn = pd.concat(df_list, ignore_index=True)
|
| 128 |
|
| 129 |
-
#
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
(df_ctn[last_mile_col].str.upper() == 'GOFO') |
|
| 143 |
-
(df_ctn[last_mile_col].str.upper() == 'USPS')
|
| 144 |
-
]
|
| 145 |
-
grouped = df_channel.groupby(['MAWB', 'Channal_name']).size().reset_index(name='CTN Count')
|
| 146 |
-
st.dataframe(grouped, use_container_width=True)
|
| 147 |
else:
|
| 148 |
-
st.warning("
|
|
|
|
| 116 |
|
| 117 |
with tabs[1]:
|
| 118 |
st.header("Upload CTN File for Last Mile Summary")
|
| 119 |
+
ctn_files = st.file_uploader("Upload one or more Excel files with Last Mile Service",
|
| 120 |
+
type=["xlsx"], key="ctn_upload", accept_multiple_files=True)
|
| 121 |
|
| 122 |
if ctn_files:
|
| 123 |
df_list = []
|
|
|
|
| 127 |
|
| 128 |
df_ctn = pd.concat(df_list, ignore_index=True)
|
| 129 |
|
| 130 |
+
# Columns of interest
|
| 131 |
+
carton_col = "No. Large box"
|
| 132 |
+
last_mile_col = "Last mile service"
|
| 133 |
+
|
| 134 |
+
# ✅ Count unique cartons by last mile service
|
| 135 |
+
st.subheader("Unique Cartons by Last Mile Service")
|
| 136 |
+
if carton_col in df_ctn.columns and last_mile_col in df_ctn.columns:
|
| 137 |
+
unique_summary = (
|
| 138 |
+
df_ctn.groupby(last_mile_col)[carton_col]
|
| 139 |
+
.nunique()
|
| 140 |
+
.reset_index(name="Unique Carton Count")
|
| 141 |
+
)
|
| 142 |
+
st.dataframe(unique_summary, use_container_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
else:
|
| 144 |
+
st.warning(f"Columns '{carton_col}' or '{last_mile_col}' not found in uploaded file(s).")
|