{"id":"code-work-re-pandas-buyer-shortlist","audience":"real-estate","category":"coding","track":"coding","technique":"context","title":"Shortlist listings for a buyer with pandas","free":false,"task":"Write a pandas script that reads listings.csv and writes shortlist.csv for your buyers, the Okafors: price at most 650,000, at least 3 beds, and zip 97211, 97217 or 97227 only. Add a price_per_sqft column rounded to whole dollars, sort by it from lowest to highest, keep only the top 5, and don't write the index. One code block, at most 12 lines, then under 25 words outside the code.","materialLabel":"Listings export, first rows (attached to your prompt automatically)","material":"listings.csv - MLS export for North Portland, Nov 5\n\naddress,zip,price,beds,baths,sqft,status\n14 Alder Ln,97211,615000,3,2,1492,Active\n88 Cedar Row #4,97217,389000,2,1,860,Active\n301 Fir St,97227,649000,4,2,1720,Active\n55 Oak Ave,97203,520000,3,1,1310,Active\n1200 Elm Ct,97211,680000,3,2,1600,Active\n76 Ash Way,97217,598000,3,2,1405,Pending\n\nNotes from Nina (team lead):\n- The Okafors were pre-approved last week and want to see a short list on Saturday.\n- They work near the Mississippi district, which is why only those zips.\n- The export has about 300 rows.\n- Status is updated nightly; pending homes can still fall through, so we leave them in.\n- Square footage comes from county records and is sometimes a year out of date.\n- The Okafors care more about value for money than about the lowest sticker price.\n- Baths don't matter to them as long as there's at least one.","rules":[{"type":"codeBlocks","count":1},{"type":"maxCodeLines","max":12},{"type":"maxProseWords","max":25}],"mistakes":[{"title":"Not giving the buyer's limits","why":"The AI can't know the Okafors' budget, beds or zips.","fix":"Add: \"Price at most 650,000, 3+ beds, zips 97211, 97217, 97227.\"","checks":["r0"]},{"title":"Leaving the ranking open","why":"The AI sorts by price, or adds a column with long decimals.","fix":"Add: \"Add price_per_sqft rounded to whole dollars, lowest first.\"","checks":["r1"]},{"title":"Leaving the output open","why":"The AI keeps every match and writes the index.","fix":"Add: \"Top 5 only, shortlist.csv, index=False.\"","checks":["r2"]},{"title":"Getting a menu of options","why":"The AI likes to offer two or three versions of the script, so you're left to pick and test them yourself.","fix":"Add: \"Give one script only, in one code block, no alternatives.\"","checks":["codeBlocks","maxCodeLines"]},{"title":"Getting a tutorial","why":"By default the AI explains every part of the code at length, which you then have to scroll past.","fix":"Add: \"After the code, one line under 12 words. Nothing else.\"","checks":["maxProseWords"]}],"promptHints":[{"label":"Gives the budget and beds","patterns":["650","3 beds|three beds|beds"]},{"label":"Gives the zips","patterns":["97211","97217","97227","zip"]},{"label":"Sets the ranking","patterns":["price_per_sqft","per (sq|square)","lowest"]},{"label":"Sets the output","patterns":["top 5","head\\(5\\)","index=false"]},{"label":"Asks for one answer only","patterns":["\\b(one|single|1)\\s+(script|code block|block|version)","only one","no (alternatives|options|other versions)"]}],"hint":"The export has every listing; only you know the buyers' limits. Tell the AI those, how to rank, and how many to keep.","rubricLabels":["Filters price <= 650000, beds >= 3 and zip in 97211, 97217 and 97227 (for example zip.isin([...])), so 55 Oak Ave and 1200 Elm Ct are left out","Adds price_per_sqft as price / sqft rounded to whole dollars and sorts it from lowest to highest","Keeps only the first 5 rows (head(5)) and writes shortlist.csv with index=False"]}