Welcome to New York City, one of the most-visited cities in the world. There are many Airbnb listings in New York City to meet the high demand for temporary lodging for travelers, which can be anywhere between a few nights to many months. In this notebook, we will take a closer look at the New York Airbnb market by combining data from multiple file types like .csv
, .tsv
, and .xlsx
.
Recall that CSV, TSV, and Excel files are three common formats for storing data. Three files containing data on 2019 Airbnb listings are available to you:
data/airbnb_price.csv
listing_id
: unique identifier of listingprice
: nightly listing price in USDnbhood_full
: name of borough and neighborhood where listing is located
data/airbnb_room_type.xlsx This is an Excel file containing data on Airbnb listing descriptions and room types.
listing_id
: unique identifier of listingdescription
: listing descriptionroom_type
: Airbnb has three types of rooms: shared rooms, private rooms, and entire homes/apartments
data/airbnb_last_review.tsv This is a TSV file containing data on Airbnb host names and review dates.
listing_id
: unique identifier of listinghost_name
: name of listing hostlast_review
: date when the listing was last reviewed
Our goals are to convert untidy data into appropriate formats to analyze, and answer key questions including:
- What is the average price, per night, of an Airbnb listing in NYC?
- How does the average price of an Airbnb listing, per month, compare to the private rental market?
- How many adverts are for private rooms?
- How do Airbnb listing prices compare across the five NYC boroughs?
# We've loaded your first package for you! You can add as many cells as you need.
import numpy as np
import pandas as pd
def clean_currency(x):
""" If the value is a string, then remove currency symbol and delimiters
otherwise, the value is numeric and can be converted
"""
if isinstance(x, str):
return(x.replace('dollars', ''))
return(x)
df_price= pd.read_csv('data/airbnb_price.csv')
df_price.head()
Cleaning the price column
df_price_copy= df_price.copy()
df_price_copy['price'].apply(clean_currency).astype('float')
df_price_copy.head()
df_price_copy.dtypes
# df_price_copy['avg_price'] = df_price_copy['price'].mean(axis=0)
looking for outliers
df_price_copy.describe()
df_rooms = pd.read_excel('data/airbnb_room_type.xlsx')
df_rooms.head()
df_reviews = pd.read_table('data/airbnb_last_review.tsv')
df_reviews.head()
Average Price Column