Spaces:
Sleeping
Sleeping
Pavlo Kostianov
commited on
Commit
Β·
82bc971
1
Parent(s):
a6bbf7e
Improve Budget Sheet handling
Browse files
app.py
CHANGED
|
@@ -25,13 +25,30 @@ df2_all = pd.read_excel(
|
|
| 25 |
df1 = {}
|
| 26 |
for sheet, raw_df in df1_all.items():
|
| 27 |
if sheet == "Budget":
|
| 28 |
-
# Load
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
os.path.join("data_source", "OC Onboarding Information.xlsx"),
|
| 31 |
sheet_name="Budget",
|
| 32 |
header=2,
|
| 33 |
-
nrows=
|
| 34 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
elif sheet == "Rooms per category":
|
| 36 |
# use row 4 as header
|
| 37 |
df1[sheet] = pd.read_excel(
|
|
@@ -64,17 +81,29 @@ for sheet, raw_df in df2_all.items():
|
|
| 64 |
# Build schema info for prompts
|
| 65 |
def get_schema_info():
|
| 66 |
lines = ["Report 1 - OC Onboarding Information:"]
|
|
|
|
| 67 |
for sheet, df in df1.items():
|
| 68 |
-
if sheet == "
|
| 69 |
-
lines.append(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
else:
|
| 71 |
lines.append(f"Sheet: {sheet}, Columns: {list(df.columns)}")
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
|
|
|
| 78 |
lines.append("\nReport 2 - The Alex Ideas Report:")
|
| 79 |
for sheet, df in df2.items():
|
| 80 |
lines.append(f"Sheet: {sheet}, Columns: {list(df.columns)}")
|
|
@@ -83,6 +112,7 @@ def get_schema_info():
|
|
| 83 |
lines.append(f"Example row: {sample}")
|
| 84 |
except Exception:
|
| 85 |
lines.append("Example row: [no data available]")
|
|
|
|
| 86 |
return "\n".join(lines)
|
| 87 |
|
| 88 |
schema_info = get_schema_info()
|
|
@@ -126,9 +156,11 @@ If absolutely no relation to provided sheets, respond with:
|
|
| 126 |
|
| 127 |
The reports are OC Onboarding Information and The Alex Ideas Report.
|
| 128 |
OC Onboarding Information (df1) is the initial hotel data including a budget set by the hotel for the year.
|
|
|
|
|
|
|
| 129 |
The Alex Ideas Report (df2) is the real reports about revenue of the hotel for the year.
|
| 130 |
|
| 131 |
-
They have the following schema (sheet names, columns, and example rows, but
|
| 132 |
{schema_info}
|
| 133 |
|
| 134 |
The user asked:
|
|
|
|
| 25 |
df1 = {}
|
| 26 |
for sheet, raw_df in df1_all.items():
|
| 27 |
if sheet == "Budget":
|
| 28 |
+
# Load raw first
|
| 29 |
+
budget_raw = pd.read_excel(
|
| 30 |
+
os.path.join("data_source", "OC Onboarding Information.xlsx"),
|
| 31 |
+
sheet_name="Budget",
|
| 32 |
+
header=None
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
# Part 1: detailed breakdown (rows 3β20 with headers at row 3)
|
| 36 |
+
budget_details = pd.read_excel(
|
| 37 |
os.path.join("data_source", "OC Onboarding Information.xlsx"),
|
| 38 |
sheet_name="Budget",
|
| 39 |
header=2,
|
| 40 |
+
nrows=17 # rows 3β19 (inclusive)
|
| 41 |
)
|
| 42 |
+
|
| 43 |
+
# Part 2: summary section (rows 21β33)
|
| 44 |
+
# Take row 3 (index 3 in header=None) as column headers
|
| 45 |
+
summary_headers = budget_raw.iloc[3].tolist()
|
| 46 |
+
budget_summary = budget_raw.iloc[21:33].reset_index(drop=True)
|
| 47 |
+
budget_summary.columns = summary_headers
|
| 48 |
+
|
| 49 |
+
# Add into df1 dict
|
| 50 |
+
df1["Budget_Details"] = budget_details
|
| 51 |
+
df1["Budget_Summary"] = budget_summary
|
| 52 |
elif sheet == "Rooms per category":
|
| 53 |
# use row 4 as header
|
| 54 |
df1[sheet] = pd.read_excel(
|
|
|
|
| 81 |
# Build schema info for prompts
|
| 82 |
def get_schema_info():
|
| 83 |
lines = ["Report 1 - OC Onboarding Information:"]
|
| 84 |
+
|
| 85 |
for sheet, df in df1.items():
|
| 86 |
+
if sheet == "Budget_Details":
|
| 87 |
+
lines.append("Sheet: Budget_Details (rows 3β20). Contains detailed breakdown by channel/segment.")
|
| 88 |
+
elif sheet == "Budget_Summary":
|
| 89 |
+
lines.append("Sheet: Budget_Summary (rows 21β33). Contains summary metrics (totals, occupancy %, RevPAR, room capacity, date ranges).")
|
| 90 |
+
# Add all rows as examples
|
| 91 |
+
try:
|
| 92 |
+
all_rows = df.to_dict(orient="records")
|
| 93 |
+
lines.append("Example rows:")
|
| 94 |
+
for row in all_rows:
|
| 95 |
+
lines.append(str(row))
|
| 96 |
+
except Exception:
|
| 97 |
+
lines.append("Example rows: [no data available]")
|
| 98 |
else:
|
| 99 |
lines.append(f"Sheet: {sheet}, Columns: {list(df.columns)}")
|
| 100 |
+
# Add one example row for context
|
| 101 |
+
try:
|
| 102 |
+
sample = df.head(1).to_dict(orient="records")[0]
|
| 103 |
+
lines.append(f"Example row: {sample}")
|
| 104 |
+
except Exception:
|
| 105 |
+
lines.append("Example row: [no data available]")
|
| 106 |
+
|
| 107 |
lines.append("\nReport 2 - The Alex Ideas Report:")
|
| 108 |
for sheet, df in df2.items():
|
| 109 |
lines.append(f"Sheet: {sheet}, Columns: {list(df.columns)}")
|
|
|
|
| 112 |
lines.append(f"Example row: {sample}")
|
| 113 |
except Exception:
|
| 114 |
lines.append("Example row: [no data available]")
|
| 115 |
+
|
| 116 |
return "\n".join(lines)
|
| 117 |
|
| 118 |
schema_info = get_schema_info()
|
|
|
|
| 156 |
|
| 157 |
The reports are OC Onboarding Information and The Alex Ideas Report.
|
| 158 |
OC Onboarding Information (df1) is the initial hotel data including a budget set by the hotel for the year.
|
| 159 |
+
- "Budget_Details": line-item breakdown (channels, rates, revenue, etc.)
|
| 160 |
+
- "Budget_Summary": summary rows (total occupancy, RevPar for each month, etc.)
|
| 161 |
The Alex Ideas Report (df2) is the real reports about revenue of the hotel for the year.
|
| 162 |
|
| 163 |
+
They have the following schema (sheet names, columns, and example rows, but Budget_Summary sheet is fully loaded):
|
| 164 |
{schema_info}
|
| 165 |
|
| 166 |
The user asked:
|
data_source/~$OC Onboarding Information.xlsx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ba618d8286013600f65acebe72668364adb0684e160cc6ef2f3bf68995fddd5d
|
| 3 |
+
size 165
|
data_source/~$The Alex Ideas Report.xlsx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ba618d8286013600f65acebe72668364adb0684e160cc6ef2f3bf68995fddd5d
|
| 3 |
+
size 165
|