Pulse of the City – Bezawit Ayalew

2023-09-16

R Markdown

data <- read.csv('Craiglist.csv')
head(data)
##   LISTING_ID LISTING_YEAR LISTING_MONTH LISTING_DAY LISTING_TIME
## 1 7074514616         2020      February          13     14:59:15
## 2 7074516499         2020      February          13     15:02:11
## 3 7074521199         2020      February          13     15:08:58
## 4 7074742850         2020      February          13     19:46:28
## 5 7075241085         2020      February          14     17:08:48
## 6 7075306172         2020      February          14     18:27:59
##          RETRIEVED_ON
## 1 2020-04-28 20:27:45
## 2 2020-04-28 20:27:40
## 3 2020-04-28 15:07:04
## 4 2020-04-27 17:43:17
## 5 2020-04-28 07:46:54
## 6 2020-04-28 05:02:33
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    BODY
## 1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         Please call us for your tour: show contact info Please visit us @ www.PARK-STREET-LOFTS.com The New Park Street Lofts are beautiful. The New Park Street Lofts offer Incredible Natural Light. The New Park Street Lofts offer unparalleled convenience. The New Residences at Park Street Lofts are ideally located near all major employers. The New Park Street Lofts are ideally Located near all Travel Routes: Mass Pike, I91, 391, 291 The New Park Street Lofts are Ideally Located near all Entertainment. The New Park Street Lofts offer exceptional access to MGM's Entertainment Complex. (It's across the Street.) The New Park Street Lofts are unlike anything you've experienced before. The New Park Street Lofts . . . Just Incredible. The New Park Street Lofts are Available Now! Call Now to schedule your tour: ASK FOR BELLA show contact info Limited availability.
## 2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              We're Waiting for You! MustSeeProperties.com Has Awesome Apartments Available and On Sale!!!! Amazing Apartments Available!!! Going FAST! CHICOPEE, WESTFIELD, WEST SPRINGFIELD, SPRINGFIELD, SOUTHWICK CALL NOW: show contact info YOU CAN SHOP AROUND IF YOU LIKE . . .BUT DON'T RENT UNTIL YOU SEE US! WE WILL NOT BE BEAT!!! DON'T MISS OUR FALL SALE . . . IT'S GOING ON NOW! CALL: show contact info ASK FOR BELLA! APARTMENTS STARTING AT $795!!!
## 3                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Tekoa Mountain Apartments has limited but great availability! 1 Bedroom! 2 Bedroom! Free HEAT! Free HOT WATER! PET FRIENDLY! WHY PAY MORE!! INCREDIBLEARLY 2020 SALE GOING ON NOW! Minutes to WSU! Walk the unofficial WSU trail to class in minutes! Incredible Specials! STARTING AT $1,195! CALL NOW: show contact info ASK FOR BELLA!! www.MustSeeProperties.com
## 4 PROPERTY INFO ID: 36735874Rent: 1250 / MonthBeds: 2Bath: 2Available Date: 04/01/2020Pet: Cats & Small Dogs OnlyRent Includes:: Hot WaterParking:: Included, Outdoor, 2 Spaces Available 4-1-20 Fourth floor two bedroom two bath in 6 story brick building with elevator.... Cat and small dog under 15 lbs ok..... Hotwater included in the rent...Tenant pays electric for heat,cooking and lights... Plenty of off street parking included.... Live in superintendent for maint.... Unit Features: -Hardwood Floors -Modern bathrooms -Modern kitchen with fridge,stove,rangehood,dishwasher/disposal -Central A/C -Great closet space -Owner checks work,landlord references and runs a credit check -To move in you need First and Security Deposit with good references -One year lease required -Call John @Prestige Realty show contact info FEATURESCarpetCat FriendlyCentral AirCloset SpaceDishwasherDisposalDog FriendlyElectric HeatElectric StoveElevatorHigh CeilingHigh CeilingsHot Water IncludedLiving RoomMod BathMod KitchenModern BathModern KitchenMultiple Unit BuildingNew WindowsOn-Site SuperParking IncludedRefrigerator Real Estate Broker John L. Hanrahan show contact info FOR MORE EXCLUSIVE LISTINGS VISIT: http://www.prestigerentalsolutions.com Anti discrimination Policy- All apartments advertised by Prestige Rental Solutions are available on an equal opportunity basis. All real estate advertised herein is subject to the federal Fair Housing Act and the Massachusetts state law, M.G.L. c.151B, which makes it illegal to advertise any preference, limitation, or discrimination , or discriminate against any person because of race, color, religion, sex, disability ,family status, veteran status, gender identity, sexual orientation, genetic information , ancestry, martial status, national origin or because the person is a member of the armed forces.
## 5                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Big 4 Bedroom Fully Renovated off Shrewsbury Street w/ 4 Large Bedrooms, Modern Eat-in kitchen, Luxury Tiled Bathrooms, Washer/dryer Hookups, Very Efficient Gas Heat, High Ceilings, Walk-in Closets & New Flooring!! PLEASE CONTACT PAUL LATINO OF RE/MAX ADVANTAGE show contact info !!
## 6                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  PROPERTY INFO ID: 32252124Rent: 2275 / MonthBeds: 2Bath: 1Available Date: 02/23/2020Pet: Cats OnlyRent Includes:: Heat, Hot WaterParking:: For Rent, Outdoor Located upon the backdrop of the Southwest Corridor Bike Path & Trail, and sitting adjacent to the MBTA's Forest Hills Station, South St brings stylish apartment living and a community atmosphere to Boston's historic JP neighborhood. Walk to bars, restaurants, cafes, galleries, museums and shopping destinations along Centre Street in minutes. Perfect for commuting, the Orange Line and Commuter Rail are right outside your front door. Unit available Feb 23 or March 1st No Broker Fee Real Estate Broker John L. Hanrahan show contact info FOR MORE EXCLUSIVE LISTINGS VISIT: http://www.prestigerentalsolutions.com Anti discrimination Policy- All apartments advertised by Prestige Rental Solutions are available on an equal opportunity basis. All real estate advertised herein is subject to the federal Fair Housing Act and the Massachusetts state law, M.G.L. c.151B, which makes it illegal to advertise any preference, limitation, or discrimination , or discriminate against any person because of race, color, religion, sex, disability ,family status, veteran status, gender identity, sexual orientation, genetic information , ancestry, martial status, national origin or because the person is a member of the armed forces.
##   PRICE AREA_SQFT ALLOWS_CATS ALLOWS_DOGS                 ADDRESS
## 1  1399        NA          NA          NA            (google map)
## 2   795        NA          NA          NA            (google map)
## 3  1195        NA          NA          NA            (google map)
## 4  1250       950           0           1         Saint Joseph St
## 5  1550        NA           1           1            (google map)
## 6  2275       900           1           0 South St near Arbor Way
##                         LOCATION    CT_ID_10
## 1                    Springfield 25013801101
## 2               West Springfield 25013801101
## 3                  WESTFIELD, MA 25013812702
## 4                     Fall River 25005640600
## 5 Worcester -- Shrewsbury STREET 25027730402
## 6                  Jamaica Plain 25025981000
# Assuming your dataframe is named 'df'
dimensions <- dim(data)

# Extract the number of rows and columns
num_rows <- dimensions[1]
num_cols <- dimensions[2]

# Print the results
cat("Number of rows:", num_rows, "\n")
## Number of rows: 312788
cat("Number of columns:", num_cols, "\n")
## Number of columns: 14
# Assuming your dataframe is named 'df' and the column is named 'year'
unique_years <- unique(data$LISTING_YEAR)

# Print the unique years
cat("Unique years in the 'year' column:", unique_years, "\n")
## Unique years in the 'year' column: 2020 2021 2022 2023 NA
# To get the total count of unique years:
num_unique_years <- length(unique_years)
cat("Total number of unique years:", num_unique_years, "\n")
## Total number of unique years: 5
# Step 1: Sample data by location and month while considering at least three unique listing years
sampled_data <- data %>%
  group_by(LOCATION, LISTING_MONTH) %>%
  filter(length(unique(LISTING_YEAR)) >= 3) %>%
  filter(LOCATION == 'Cambridge') %>%
  ungroup()

# Step 2: Ensure only distinct years are retained and select three random rows
#filtered_data <- sampled_data %>%
 # distinct(LISTING_YEAR, .keep_all = TRUE) %>%
  #sample_n(3)  # Select three random rows from the distinct years

# Step 3: Print the resulting filtered and sampled data
head(sampled_data)
## # A tibble: 6 × 14
##   LISTING_ID LISTING_YEAR LISTING_MONTH LISTING_DAY LISTING_TIME RETRIEVED_ON   
##        <dbl>        <int> <chr>               <int> <chr>        <chr>          
## 1 7076315426         2020 February               16 13:42:05     2020-04-28 17:…
## 2 7078659436         2020 February               19 23:45:22     2020-04-28 17:…
## 3 7079053091         2020 February               20 17:59:59     2020-04-27 20:…
## 4 7080759800         2020 February               23 12:54:06     2020-04-27 19:…
## 5 7081607146         2020 February               24 19:42:27     2020-04-28 17:…
## 6 7083504659         2020 February               27 18:56:36     2020-04-27 21:…
## # ℹ 8 more variables: BODY <chr>, PRICE <int>, AREA_SQFT <dbl>,
## #   ALLOWS_CATS <int>, ALLOWS_DOGS <int>, ADDRESS <chr>, LOCATION <chr>,
## #   CT_ID_10 <dbl>
# Sample data (replace this with your actual data)
data2 <- data[c('LISTING_MONTH', 'PRICE')]

# Calculate the average price for each month
library(dplyr)
monthly_avg_prices <- data2 %>%
  group_by(LISTING_MONTH) %>%
  summarise(avg_price = mean(PRICE))

# Create a bar graph
library(ggplot2)
ggplot(data2$monthly_avg_prices, aes(x = data2$LISTING_MONTH, y = data2$PRICE)) +
  geom_bar(stat = "identity", fill = "blue") +
  labs(x = "Month", y = "Average Price", title = "Average Price of Apartment Listings per Month") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))  # Rotate x-axis labels for better readability
## Warning: Removed 1 rows containing missing values (`position_stack()`).
# Load the dplyr package if it's not already loaded
library(dplyr)

# Count the number of listings per month
COUNT <- data %>%
  group_by(LISTING_MONTH) %>%
  summarise(listing_count = n())


ggplot(COUNT, aes(x = LISTING_MONTH, y = listing_count)) +
  geom_bar(stat = "identity", fill = "red") +
  labs(x = "Month", y = "Number of Listings", title = "Number of Listings per Month") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))  # Rotate x-axis labels for better readability
# Load the dplyr package if it's not already loaded
library(dplyr)

# Count the number of listings per month
COUNT2 <- sampled_data %>%
  group_by(LISTING_MONTH) %>%
  summarise(listing_count = n())

# Print the result or store it in a variable for further use
#print(count_per_month)

ggplot(COUNT2, aes(x = LISTING_MONTH, y = listing_count)) +
  geom_bar(stat = "identity", fill = "green") +
  labs(x = "Month", y = "Number of Listings", title = "Number of Listings per Month in Cambridge") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))  # Rotate x-axis labels for better readability
sampled_data2 <- data %>%
  group_by(LOCATION, LISTING_MONTH) %>%
  filter(length(unique(LISTING_YEAR)) >= 3) %>%
  filter(LOCATION == 'Cambridge') %>%
  filter(PRICE >= '300' ) %>%
  ungroup()
# Count the number of listings per month
COUNT3 <- sampled_data2 %>%
  group_by(LISTING_MONTH) %>%
  summarise(listing_count = n())

# Print the result or store it in a variable for further use
#print(count_per_month)

ggplot(COUNT3, aes(x = LISTING_MONTH, y = listing_count)) +
  geom_bar(stat = "identity", fill = "black") +
  labs(x = "Month", y = "Number of Listings", title = "Number of Listings per Month in Cambridge without Prices less than 300 ") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))  # Rotate x-axis labels for better readability

Three interesting pieces to look at from the data are the average price by month, the number of listings per month, and the number of listings per month for a specific location. I created 3 bar graphs that aim to see if there is a pattern for each category.

Average price per month, from the graph above we can see that during winter time the average price of listings falls. The month with the lowest average price is February and the month with the highest average price is May and June. The insights this provides is about the city perhaps during colder seasons people demand less and this reduces the supply which affects the price as it lowers it. For further analysis let’s look at if the pattern has anything to do with the total number of listings.

Number of listings per month, similar to the average price per month graph the total number of listings is lowest in February, but highest in April. The insight from this perhaps might be that property owners start putting more listings up to prepare for spring and summer. From this pattern, we can observe that weather does affect the decision of the housing market in Boston City.

Number of Listings in Cambridge per month, the first two graphs aim to see if there is a pattern in the aggregate number of listings and prices for all the cities in the Boston area. Does this pattern hold true for specific locations or is it only for the aggregate cities? To check to see if this pattern holds true for a specific location let’s look at the distribution of listings specifically in Cambridge. From the bar graph above we observe a similar pattern except in having a lower number of listings in colder months, however, the lowest number of listings is in January, and the graph shows that the difference in the number of listings per month is not as great as the graph with the aggregate cities. This means the number of listings per month is around the same per month except for specific months like January, November, and October. In addition, we can also observe that September has a very high number of listings and May has a very low number of listings. Why is this? What is going on in Cambridge specifically that is contributing to a higher number of listings in September. There are a lot of schools located around the area, is it because students start school in September? There are quite a few insights when we look at the graph in Cambridge that would be interesting to investigate further in the future.

Two strange observations from the data set that I have observed are there were listings for prices that are lower than 300, even though they are apartments with many bedrooms the price should be higher. This brings the question of why are the apartments listed for much lower prices. The second strange piece I found in the data set is that there were a lot of listings that didn’t include area square feet at all or had an area square feet as large as 710940. I created a graph after removing the prices that have lower prices than $300 to see if it changes the graphs I created to see if it changes the patterns observed in the previous graphs.

After observing the graph of the number of listings in Cambridge by month after removing the listings that were put for a lower price(less than 300) it made a drastic difference in my results there two graphs look different as there is a bigger difference between the number of listings between the months. This shows that further cleaning of the data is needed to make sure the observation is accurate.


Leave a comment