Data Study on Apartments in Manhattan
The skills the author demoed here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.
Introduction
Manhattan is without a doubt one of the best cities in the world to live in. Data shows the city is rich in history, culture, art and vibrancy, which never ceases to amaze. It is the city that never sleeps and there is always something to do. Most people want to move to this incredible city and are willing to compromise luxury by living in shoebox apartments and paying crazy-high rent. The rental market in New York is one of the most expensive in the country. How you chose to live can be as important as WHERE you choose to live. The high volume of demand makes the NYC real estate market very expensive.
Looking for an apartment in Manhattan used to be far more stressful. However with the arrival of numerous rental websites and apps, house hunting has never been so easy and convenient. Trulia is one of the many online residential real estate websites that gives access to housing information for people interested in renting apartments in the United States. It lists information such as price, number of bedrooms and bathrooms, school rating and crime level. There is a wide range of housing options which people can chose from.
Data Extraction and Transformation
The structure of the webpages was in 2 different formats for Apartment Community Complex and Individual Apartments. This project only focused on Individual apartments which had only one type of bedroom and ranged from one-bedroom to seven-bedroom apartments. As you can see in the picture below, the apartment consisted of only one type of bedroom and the names for the apartments were given on the basis of their location. Information such as rent, area, address and geo-location were scraped from the page.Clicking on the apartment name takes you to the webpage which has detailed information about the apartment such as school and crime ratings.
After developing the code in python, I was able to scrape the information for all apartments in Manhattan by looping through each page. In total, I scraped data for 6767 individual apartments which were exported into excel. I did some data munging and cleaning to get the data in the proper structure to do further analysis. The apartments were divided into 10 Manhattan neighborhoods based on postal code information. In total there were 19 variables for each apartment.
The Rental App
After data preparation, I built a Rental App using R Shiny which displays the apartments on the interactive map from their geo location. The apartments have been classified into 4 classes that are 1 bedroom, 2 bedroom, 3 bedroom and more than 3 bedroom to make visualization more interpretable. The users can filter their apartment search based on neighborhood, number of bedrooms and bathrooms, and rental price. We can get additional information about the apartments by clicking on the points which display pop up boxes with apartment details. Similarly, the small bar-graph shows the frequencies of apartment types that are currently displayed on the interactive maps. We can also view the database of the apartments by clicking on the “Data” tab.
Analyzing the data
This Shiny app analyzes the data and gives information about total number of apartment types and median prices for each neighborhood in Manhattan. It gives users the option to select the type of apartment they want to get information about. In the figure below, we analyze one and two bedroom apartments.
Analyzing the bar graph for the number of apartments in each neighborhood, we can see that there are more one bedroom apartments than two bedroom apartments in most of the neighborhoods. This is particularly so in Chelsea Clinton, the Upper East Side, and the Upper West Side. In contrast, Central and East Harlem have more two bedroom apartments, and the actual number of apartments for rent in these areas is relatively low.
Looking at the bar-graph of the median prices in each neighborhood, we can see that rent prices for both one bedroom and two bedroom apartments are very high in Lower Manhattan and Chelsea Clinton. Two bedroom apartments are particularly expensive in Lower Manhattan. It is relatively cheaper to live in East Harlem or the Inwood Washington Heights area. This information can be very useful for the users to plan their rental search based on their budget.
Crime Level
Every potential renter wants to live in a place that is safe for them and their family. Each apartment has crime level ratings based on the number of crime incidents that occurred nearby the apartments. The crime level rating has been categorized into 4 groups (lowest, low, high and highest).
We are analyzing only the apartments that have the “highest” and “lowest” crime rating. We can see that there were relatively more apartments on the Upper East Side and Upper West Side that had “lowest” crime level. There were very few apartments in this region that had “highest” crime rating which tells us that these neighborhoods are relatively safe. On the other hand, there were many apartments in Greenwich Village Soho that had “highest” crime rating and very few “lowest” crime rating. Therefore we can say that it is safer to live on the upper East Side and Upper West Side areas of Manhattan than Greenwich Village Soho.
Data on School Ratings
Each apartment has ratings information for Elementary, Middle and High School based on the average rating of all schools nearby. These ratings come from “GreatSchools.com”. The ratings have been classified into 3 groups: “Above Average”, “Average” and “Below Average”.
Data on Elementary School Ratings
From the elementary schools bar graph, we can see that there were lots of apartments in the Upper East Side and Gramercy Park Murray Hill that had school ratings “Above Average”. There were more apartments in Inwood Washington Heights which had “Below Average” ratings. Overall there were more apartments with “Above Average” ratings than “Below Average” ratings in most of the neighborhoods.
Data on Middle School Ratings
We can see that there were more neighborhoods that had “average” schools, than any other type. Noteworthy are Gramercy Park and Greenwich Village for their “above average” schools. While Central Harlem and East Harlem are noteworthy for the lack of any “above average” schools.
Data on High School Rating
We can see that there are very few neighborhood that had schools rated as “Above Average”. Most neighborhoods have a higher number of schools rated as “Average” than “Below Average”. Looking at bar-graphs for Gramercy Park Murray Hill, Inwood Washington Heights and Central Harlem, we can see that there are more schools rated “Below Average” than “Average”.
Conclusion
I would like to sum up by stating that this app can be really helpful for the users who are looking to rent apartments in Manhattan. The users can improve their apartment search by filtering apartments according to their needs and playing with the interactive map to gain more insights about apartment rentals. They can also get additional ideas about the price ranges, school ratings and crime level for each neighborhood and decide which neighborhood they want to move to. Happy Apartment Hunting !!!
Future Work
- Expanding the apartment search to all boroughs of New York
- Adding more information about the apartments.
- Adding features to the map
- Building a multiple regression model to estimate price from different predictor variables
Link to the Shiny App: https://samriddhishakya.shinyapps.io/Trulia/
Link to the codes:
https://github.com/nycdatasci/bootcamp006_project/tree/master/Project3-WebScraping/Samriddhi_Trulia