Data Study on NYC Real Estate Inventory

Posted on Oct 20, 2018
The skills the author demoed here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.

Introduction

As a native New Yorker who has moved several times in the past eight years, I know that moving in the city is a difficult and tiring process. Whether you are renting or buying, the task of finding a listing online, seeing the apartment, and securing it is arduous. As NYC is home to more than 8.5 million inhabitants and not the most extensive inventory of living spaces, data records show a newly listed apartment can be snapped up within day or even hours.

For my project I wanted to scrape the inventory of a real estate agency. I chose Corcoran Group, which has thousands of listings across the five boroughs of New York City. But for this project, I was only concerned with two of them: Manhattan and Brooklyn. My objective is to find what's available in the two boroughs and to analyze it to provide useful insight for those in the market for apartments. It's possible to extrapolate generalizations about the larger NYC real estate market from the neighborhood and bedroom analysis of these two boroughs.

Data Collection/Cleaning

After reading the html code for the Corcoran search results, it was evident that the site used ajax applications, which meant using scrapy or beautiful soup package was not an option. In order to scrape the website I used the selenium package as well as use the pandas, ggplot, seaborn in the data manipulation, analysis and visualization. The search results are set up as 36 to a page with each listing a link to listings details. I wrote my code to go to each page of listings, scrape each listing for their urls and make a list of those URLs.

Data Study on NYC Real Estate Inventory

Listings

From that list, my code would iterate through into each listing URL and scrape the entire listing, only keeping the data for address, neighborhood, price, apt type(Condo/Co-op/Townhouse), number of bedrooms, bathrooms, total rooms, sqft and description. I ran into an issue at this step, though; all the listings did not use the same set template as the one below. Some listings included all of the keys I was pulling, but others were missing certain pieces of information.Data Study on NYC Real Estate Inventory

I worked through this issue by creating a dictionary for the information they did have, and if it matched the keys I was most interested in, passing it to a csv file. The end result was a listing for all 1317 Manhattan listings as well as 553 Brooklyn listings. To clean the data I had to remove dollar signs and comas from the price and change the types to an integer to be able to perform analysis on it.

Unfortunately not all the listings are complete, and using averages or interpolation would not be appropriate. Consequently, I only used complete listings with data for all keys for my analysis. However, as each listing did include a description, I was able to draw on the complete catalog of listings for my word cloud analysis. The cleaned data result was a set of listings that included 690 in Manhattan and 302 in Brooklyn.

Going forward

This could work as a living document, scraping inventory nightly to keep an ongoing list of available inventory. A trend analysis can be don on that basis.

Also including a shiny app could make it possible to view the graphs for individual neighborhoods for different criteria.

 

About Author

Kent Burgess

A data scientist with a focus on machine learning, big data, advanced statistics and analytics, R and Python development, data visualization and packages, SQL, and Git/Github. Ambitious professional with a track record of executing strategic business initiatives in...
View all posts by Kent Burgess >

Leave a Comment

No comments found.

View Posts by Categories


Our Recent Popular Posts


View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI