Craiglist New York Data Analysis and Scraping
The skills I demoed here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.
This article will go through how one would scraped data from New York Craigslist .
Craigslist is an advertisement website that people use to find jobs, housing, items for sale, services, music gigs, etc. The code used to scrape the data can be found on GitHub.
Getting the Data
To collect the data BeautifulSoup from bs4, which is a Python library that is used for pulling data from HTML files, was used. The type and length of each item was checked to see if it matched the number of posts per page, which is 120 on Craigslist. The code below shows this process:

Using the find_all method, shown in the code above. The website was examined, and the tag of each post was found. From the screenshot below it's shown that the parent tag of each posts is <li class = "result-row">.

Using the screenshot above the, the attributes that were extracted for each post were:
- Time Posted
- Neighborhoods
- Number of bedrooms
- Square Feet
- URL
- Price
After running the Beautiful Soup code, a dataframe was created that listed the values.
The code that was used to create the dataframe is shown below:

Data Analysis
The reason for this analysis was to see what factors into the pricing of Manhattan apartments, and to help people looking for apartments. The below plot shows the distributions of prices in Manhattan. From the plot most of the apartments fall in the $2000-$3000 price range. There also seems to be some outliers around the $9000-12000 range.

Regression analysis was also done between the Square footage and the Price, to see if there was any correlation between the two variables. From the scatterplot below it seems there is a slight positive correlation. However there seems to be some outliers, so square footage might not be the most reliable factor in determining the price of an apartment.

So to determine if square footage was the best indicator for determining the price, a regression plot with the best fit line was plotted. From the below plot it seems that the fit of the line for the two variables is adequate.

As stated before it seems the best fit line was adequate, and for a deeper look the correlation for the two variables was calculated.

It is not surprising that there is a slightly strong correlation between the number of bedrooms and square footage, since the more bedrooms there are the bigger the apartment should be. However there doesn't seem to be a strong correlation between price and number of bedrooms, in fact it's pretty weak.
Further analysis was done regarding the prices by neighborhood. The bar plot shows the average price per neighborhood, and the box plot gives a more in depth analysis, showing the price range for each neighborhood.


Conclusion
Out of all the neighborhoods Soho was shown to have the largest spread. However further research will need to be done to understand what's happening with Tribeca since it has no whiskers. Harlem seems to have the lowest average price per apartment. This data can help provide insight for a person looking for a apartment in Manhattan.
In the future, further data cleaning will be done, and more insight will be done into other variables. Also, further data scraping will be done with the other boroughs.