<jupyter_start><jupyter_text>Part I: How does Listings price relate to the month of the year?In this notebook we are going to see how prices of listings vary during a month of the Year.For this we'll be creating a line chart out of the AirBnB data (calendar.csv) for Boston and Seattle to draw comparisons.<jupyter_code>#importing necessary libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import utilities as u

#reading csv files into data frames for the two cities Boston and Seattle. (Data Gathering)
df_boston_calendar = pd.read_csv('./BOSTON/calendar.csv')
df_seattle_calendar = pd.read_csv('./SEATTLE/calendar.csv')
'''For this data set we are dropping NaN values as they will serve no purpose. 
Filling them with mean is not an option as it may show unwanted variations in our line charts when in
reality it's not the case '''

#dropping na from the dataset of Boston and seattle Calendar Data (Data Cleaning)
df_bost_cal = df_boston_calendar.dropna(axis=0)
df_seat_cal = df_seattle_calendar.dropna(axis=0)
#converting price to float and date string to datetime (Data Cleaning and Data Preparation)
df_bost_cal = u.convert_amount(df_bost_cal, ['price'])
df_seat_cal = u.convert_amount(df_seat_cal, ['price'])
df_bost_cal['date']=pd.to_datetime(df_bost_cal['date'])
df_seat_cal['date']=pd.to_datetime(df_seat_cal['date'])
#calculationg mean listings price for a particular date for both Boston and Seattle Data frames
d_bost=df_bost_cal.groupby('date')['price'].mean().to_frame(name='Mean_price').reset_index()
d_seat=df_seat_cal.groupby('date')['price'].mean().to_frame(name='Mean_price').reset_index()
d_bost.sort_values(by='Mean_price', ascending=False)<jupyter_output><empty_output><jupyter_text>Boston has Highest Mean prices in the month of september and lowest during March and February<jupyter_code>d_seat.sort_values(by='Mean_price', ascending=False)<jupyter_output><empty_output><jupyter_text>Seattle on the contrary has highest mean prices in the month of July<jupyter_code>'''Data Visualization
Here we are going to plot mean prices for listings in boston and seattle in a line chart'''

from matplotlib.dates import DateFormatter
#setting height and width of the plot
plt.figure().set_figheight(30)
plt.figure().set_figwidth(12)

#plotting line chart
plt.plot(d_bost['date'],d_bost['Mean_price'],color='red')
plt.plot(d_seat['date'],d_seat['Mean_price'],color='blue')

#converting date format
date_form = DateFormatter("%b-%Y")
plt.gca().xaxis.set_major_formatter(date_form)

#setting X,Y labels, title and legend
plt.gca().set(xlabel="Date",
       ylabel="Mean_Price ($)",
       title="Date Vs Mean_Listings_Price")
plt.legend(["Boston","Seattle"])
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10641399416909621, 'fraction_numerical': 0.002186588921282799, 'mean_word_length': 6.910662824207493, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '16592', 'license': 'CNRI-Python', 'n_tokens_mistral': 921, 'n_tokens_neox': 868, 'n_words': 270, 'path': 'Price Variation Over Time.ipynb', 'repo_name': 'Piyush23Rai/AirBnB', 'size': '2744'}