Airbnb Data
Zooming in on Airbnb¶
To get a clearer picture of the trend and seasonality of airbnb, we will first observe its last 6 years. Indexing to the all dates including and after 1/1/2015 and resting the end is the first task to do.
In [9]:
#Get our sample data
airbnb = df.loc['2015-01-01':]['Airbnb'].reset_index()
airbnb.columns = ['Date', 'Search']
print(airbnb)
For columns of the datetime type, we can use dt followed by a part of the date we want to return things like the year for each date, the month of each date, etc.
In [10]:
airbnb['Year'] = airbnb['Date'].dt.year
airbnb['Month'] = airbnb['Date'].dt.month
print(airbnb)
In [11]:
#Pivot the date by month and year
airbnb = airbnb.pivot('Month', 'Year', 'Search')
print(airbnb)
In [12]:
#Plot the data
ax = airbnb.plot(kind='line')
ax.set_xlabel("Month")
ax.set_ylabel("Search Index")
ax.set_title("Google Search Index Airbnb Yearly Comparison")
plt.show()