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 project, 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 This is a CSV file containing data on Airbnb listing prices and locations.
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
# Import necessary packages
import pandas as pd
import numpy as np
# Begin coding here ...
# Use as many cells as you like
df_price = pd.read_csv('data/airbnb_price.csv')
df_room = pd.read_excel('data/airbnb_room_type.xlsx')
df_review = pd.read_csv('data/airbnb_last_review.tsv', sep='\t')
print(df_price.head(5))
print(df_room .head(5))
print(df_review.head(5))
df_total = df_price.merge(df_room, on='listing_id', how='outer')
df_total = df_total.merge(df_review, on='listing_id' ,how='outer')
df_total.head()
df_total.info()
df_total['last_review'] = pd.to_datetime(df_total['last_review'])
earliest_review = min(df_total['last_review'])
recent_review = max(df_total['last_review'])
print(earliest_review)
print(recent_review)
df_total['room_type'].unique()
df_lower = df_total['room_type'].str.lower()
df_lower.head()
df_lower_count = df_lower.value_counts()
df_lower_count
private_room = df_lower_count.iloc[1]
private_room
df_total['price'] = df_total['price'].str.replace('dollars','')
df_total['price'] = df_total['price'].astype(float)
df_total['price'].info()
average_price = df_total['price'].mean()
average_price = round(average_price,2)
average_price
data = {
'first_reviewed': earliest_review,
'last_reviewed': recent_review,
'nb_private_rooms': private_room,
'avg_price' : average_price
}