<jupyter_start><jupyter_text>Business UnderstandingI will be using Airbnb data for the city of Seattle with the interest of determining where to stay based on three criteria: the popularity of the neighborhood, the most popular listings and the average price per listing in a given neighborhood. These three criteria should give a good indicator of popular and affordable destinations.  Data UnderstandingIn order to answer these questions, it is imporant to first anaylze the data. This will give us some insight on how to answer the questions of interest. The data has three dataframes in which we will anaylze.<jupyter_code>#list all the columns in the listings dataframe to find relevant data. Some plausible options are neighbourhood, 
#neighborhood_cleansed, name and price.
list(ldf)
#get a first look at the listings data
ldf[['neighbourhood_cleansed', 'name', 'price']].head()
#list all the columns in the reviews dataframe to find relevant data. Here we can use the listings_id to determine the number
#of reviews for a given listing.
list(rdf)
#get a first look at the review data
rdf.head()
#list on the columns in the calendar dataframe to find relevant data.
list(cdf)
#get a first look at the calendar data
cdf.head()<jupyter_output><empty_output><jupyter_text>Data PreparationAirbnb has provided us with clean data for the neighborhood listings, thus there are no missing values. As we can see above, Airbnb price data is a string. We need to convert this to a float to perform computations on the price. We should also check for missing price data as this could skew the average.  Q1: What are the most popular neighborhoods? This will be determined based on the total number of listings in a given neighborhood. Airbnb has provided clean data for the neighborhood listings, thus there are no missing values.<jupyter_code>listings_per_neighborhood = ldf['neighbourhood_cleansed'].value_counts()
listings_per_neighborhood[:10].plot(kind="bar", title="Top Listings", xlabel="Neighborhood", ylabel="Number of Listings")

listings_per_neighborhood.head(10)<jupyter_output><empty_output><jupyter_text>Q2: What are the most popular listings? Popular listings are determined by the number of reviews given for that listing. If there are a lot of reviews, there is a good chance it is a well known listing. Rather than show the listing_id, I have determined the listing_name from the given id. This helps understand the property better.<jupyter_code>rdf = rdf['listing_id']
top_reviewed = rdf.value_counts(ascending=False).reset_index()
top_reviewed.rename(columns={'index': 'listing_id', 'listing_id': 'reviews'}, inplace=True)

name_column =[] #This array is used to match the listing_id with the listing name.

for i in range(len(top_reviewed)):
    name_column.append(((ldf['name'].where(ldf['id'] == top_reviewed['listing_id'][i]).dropna())).iloc[0])
    
top_reviewed = top_reviewed.assign(listing_name=name_column)
top_reviewed[:10].plot(x='listing_name', y='reviews', kind="bar", title="Top Reviewed", xlabel="Listing Name", ylabel="Number of Reviews")

top_reviewed.head(10)<jupyter_output><empty_output><jupyter_text>Q3: What are the most expensive neighborhoods? This can help guests determine the right neighborhood for their price range.<jupyter_code>#check to see if there any missing prices as this could skew the results.

missing_prices = ldf['price'].isnull().sum()/ldf.shape[0]

if missing_prices == 0:
    print("No missing price data")
else:
    print(missing_prices)
#Airbnb price data is a string. We need to convert this to a float to perform computations on the price.
ldf['price'] = ldf['price'].str.replace("[$, ]", "", regex=True).astype("float")

#Group the data by neighborhood then find the average price per room according to that grouping.
average_neighborhood_price = ldf.groupby(['neighbourhood_cleansed']).mean()['price'].sort_values(ascending=False)
average_neighborhood_price[:10].plot(kind="bar", title="Most Expensive Neighborhoods", xlabel="Neighborhood", ylabel="Average Price per Room")

average_neighborhood_price.head(10)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08599269183922047, 'fraction_numerical': 0.00438489646772229, 'mean_word_length': 6.165794066317627, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '134251', 'license': 'CNRI-Python', 'n_tokens_mistral': 1195, 'n_tokens_neox': 1135, 'n_words': 479, 'path': 'Project 1.ipynb', 'repo_name': 'xKURTx/Project-1', 'size': '4105'}