Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -725,6 +725,7 @@ CRITICAL RULES:
|
|
| 725 |
8. **CONSISTENT COLUMN NAMES:** After aggregation or renaming, always use the NEW column names in subsequent operations. Track renamed columns carefully - if you rename 'Zone' to 'zone', use 'zone' everywhere after.
|
| 726 |
9. **SAFE ITERATION:** When iterating over mixed data structures, always check types before accessing attributes. Not all list items are dicts (some may be strings), not all values have `.items()`.
|
| 727 |
10. **KEY-VALUE DATA PATTERN:** Many healthcare datasets use key-value format (e.g., columns: 'Indicator'/'Value' or 'Metric'/'Amount'). To extract a specific value, filter rows by the key column, then access the value column: `df.loc[df['Indicator'] == 'Cost per client', 'Value'].iloc[0]`
|
|
|
|
| 728 |
|
| 729 |
--- USER'S SCENARIO ---
|
| 730 |
{user_scenario}
|
|
|
|
| 725 |
8. **CONSISTENT COLUMN NAMES:** After aggregation or renaming, always use the NEW column names in subsequent operations. Track renamed columns carefully - if you rename 'Zone' to 'zone', use 'zone' everywhere after.
|
| 726 |
9. **SAFE ITERATION:** When iterating over mixed data structures, always check types before accessing attributes. Not all list items are dicts (some may be strings), not all values have `.items()`.
|
| 727 |
10. **KEY-VALUE DATA PATTERN:** Many healthcare datasets use key-value format (e.g., columns: 'Indicator'/'Value' or 'Metric'/'Amount'). To extract a specific value, filter rows by the key column, then access the value column: `df.loc[df['Indicator'] == 'Cost per client', 'Value'].iloc[0]`
|
| 728 |
+
11. **CONVERT STRINGS BEFORE MATH:** Always convert strings to float/int BEFORE performing arithmetic. When parsing ranges like "8–10", split first, convert each part to float, then calculate: `values = text.split('–'); avg = (float(values[0]) + float(values[1])) / 2`
|
| 729 |
|
| 730 |
--- USER'S SCENARIO ---
|
| 731 |
{user_scenario}
|