Homework 4
Skills: 0, 1, 2, 12
Due
Sunday, Oct 11, Anywhere-on-earth
Submission
This HW, like all homeworks, is done on https://github.com and submitted on https://app.pawtograder.com. Go to Pawtograder to find the repository where the assignment should be done. Commits automatically make submissions.
While there may be automated feedback for parts of the "Programming Practice" section, ALL OF YOUR GRADE IS DETERMINED BY THE ASSIGNMENT CHAT THAT OCCURS DURING THE LAB FOLLOWING THE DEADLINE (see Assignment Chats).
Project
Project 1, Checkpoint 3, due this week, is:
- Come up with two other questions, and start trying to answer them via code.
- For one of your three questions, create a plot of the results.
Programming Practice
Reference: For all work with tables, refer to the Tables page in the menu at the top of the page!
New York City publishes tables of tax lots (pieces of land the city uses for property records). You will work with a subset of that data: lots that are mostly city-owned or otherwise tax-exempt. Each row is one lot.
The CSV is at https://raw.githubusercontent.com/neu-pdi/cs2000-public-resources/refs/heads/main/static/support/project-housing.csv. It has about 33,000 rows, so loading it may take a few seconds, and you should filter before making plots of the full table.
The columns are:
borough:MN(Manhattan),BX(Bronx),BK(Brooklyn),QN(Queens),SI(Staten Island)zipcode: ZIP code (keep this as aString)address: street address (sometimes blank)landuse: a category code, stored as a string"1"through"11"(see Problem 3)ownertype:Ccity,Mmixed city and private,Oother public (state, federal, or an authority),Pprivate,Xtax-exempt but not in the city’s ownership filelotarea: lot area in square feetbldgarea: total building floor area in square feet (0if there is no building)latitude,longitude: location of the lot
The official field descriptions are in the PLUTO Data Dictionary (a long PDF; you only need the entries for borough, land use, owner type, lot area, and building area).
Chart functions are in Plots and Charts. Calling one displays the image; you do not need to save files.
Problem 1
Load the CSV into a table named housing. Use the column names listed above. After loading, use transform-column with string-to-number-unsafe (or string-to-number-default(0)) to convert lotarea, bldgarea, latitude, and longitude to numbers. Leave zipcode and landuse as strings.
Problem 2
City-owned lots (ownertype is "C") are the ones the city can most directly decide what to do with.
Create a table city-lots containing only those rows. Then make a frequency bar chart of borough in city-lots.
In a comment, write one sentence about which borough has the most city-owned lots in this dataset, and whether that matches what you would have guessed.
Problem 3
The landuse codes are not readable on a chart. Design a function landuse-name that takes a land-use code (a String) and returns a description:
| Code | Meaning |
|---|---|
"1" | One & Two Family Buildings |
"2" | Multi-Family Walk-Up Buildings |
"3" | Multi-Family Elevator Buildings |
"4" | Mixed Residential & Commercial Buildings |
"5" | Commercial & Office Buildings |
"6" | Industrial & Manufacturing |
"7" | Transportation & Utility |
"8" | Public Facilities & Institutions |
"9" | Open Space & Outdoor Recreation |
"10" | Parking Facilities |
"11" | Vacant Land |
Include a doc: string and where: tests for at least three codes.
Then use build-column to create housing-labeled, which is housing plus a column landuse-label of those descriptions. Make a frequency bar chart of landuse-label in housing-labeled.
Problem 4
A histogram of lotarea on the full table is hard to read: a few lots are parks or airports of tens of millions of square feet.
Create modest-lots by keeping only rows whose lotarea is at least 1 and at most 20000. Make a histogram of lotarea on modest-lots. Try two different bin-width values (for example 1000 and 5000). In a comment, say which width is more useful and why.
Problem 5
Latitude and longitude let you draw a rough map.
Create manhattan containing only rows whose borough is "MN". Make a scatter plot with longitude on the x-axis and latitude on the y-axis.
Problem 6
Vacant city-owned land is a planning decision: housing, parks, schools, or leaving it empty all serve different people.
Using city-lots from Problem 2, create city-vacant containing lots whose landuse is "11". You do not have to plot this table.
Identify two stakeholder groups who would care how those lots are used. For each, write an interest or value that includes because (why that interest matters for that group). Put your answer in comments:
# stakeholder1: cares about X because ...
# stakeholder2: cares about Y because ...