<jupyter_start><jupyter_text>Finding the Best Neighborhood in Pittsburgh:  Factoring in Property Values  Introduction The perception of a neighborhood often stems from the quality of its buildings and home. This dataset seeks to capture that perception quantitatively, rather than empirically by driving through each neighborhood and noting the condition of each house and building. To accomplish this, I use a dataset that includes all property sales around Pittsburgh since 2013, including the sale price and zip code for each property. In the analysis, I group all properties by zip code, and then find the mean to determine the average sold price since 2013, which I refer to as the property value.  Data borrowed from https://data.wprdc.org/dataset/real-estate-sales  Getting Started<jupyter_code>import pandas as pd
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
# Importing the data
property_data = pd.read_csv("PghPropertySaleData.csv", low_memory = False)
# Previewing the data
property_data.head(5)
# In the preview, I noticed that the property in the fourth row sold for a price of $0.
# Looking through the .dbf file, I noticed that there are several other extremely low sold prices, such as $0, $1, and $10. 
# Therefore, I am only considering prices above $1,000 to mitigate the infuence of global outliers. 
property_data = property_data[property_data.PRICE > 1000]
# In importing the CSV file, the zip codes were turned into floats. This will cast them back into the int data type
property_data['PROPERTYZIP'] = property_data['PROPERTYZIP'].astype(int)
# Finding the mean of the property sold prices for all properties sharing the same zip code
price_property_data = property_data[['PROPERTYZIP','PRICE']].groupby(['PROPERTYZIP']).mean()
price_property_data
# Rounding the mean property sales prices to the nearest dollar
price_property_data['PRICE'] = price_property_data['PRICE'].astype(int)
# Sorting the data by price
price_property_data.sort_values(by=['PRICE'],inplace=True)
price_property_data.head(10)<jupyter_output><empty_output><jupyter_text>Establishing a points system and price bracketsZip codes with properties within a certain threshold will be assigned a fixed number of points.          Team members' data sets also utilize a point system.         The neighborood with the highest combined number of points will be considered the best.<jupyter_code># First, price brackets need to be established. To do this, I will divide the distribution into five tiers, based on percentiles.

# Creating a new column called "Percentile Rank", which shows the percentage of prices that any one price is greater than.
price_property_data['Percentile Rank'] = price_property_data.PRICE.rank(pct = True)
# Now, I am creating conditions for the program to check in order to set a point value based on the Percentile Rank values. 

conditions = [
    (price_property_data['Percentile Rank'] <= .2),
    (price_property_data['Percentile Rank'] > .2) & (price_property_data['Percentile Rank'] <= .4),
    (price_property_data['Percentile Rank'] > .4) & (price_property_data['Percentile Rank'] <= .6),
    (price_property_data['Percentile Rank'] > .6) & (price_property_data['Percentile Rank'] <= .8),
    (price_property_data['Percentile Rank'] > .8)]
# The points work with the above conditions. If the first condition is met (percentile rank below .2), one point is assigned.
# If the second condition is met (percentile rank below or equal to .4 and greater than .2), then two poitns are assigned.
# This method gives more points to zip codes with higher percentile prices.
points = ['1', '2', '3', '4', '5']
# Making a new column called "Points" and adding point values based on the above conditions.
price_property_data['Points'] = np.select(conditions, points)
# Sorting the data first by points, and then by price.
price_property_data.sort_values(by=['Points', 'PRICE'],inplace=True, ascending=False)
price_property_data.head(5)<jupyter_output><empty_output><jupyter_text>As seen above, the best neighborhood judged purely from property values is 15275, which is Pittsburgh. There is no specific neighborhood attached to that zip code, nor the runner-up, so I will conclude that 15222 - Downtown - is the best neighborhood.<jupyter_code># Grabbing the data to put in the final notebook
price_property_data.to_csv('property_data.csv')<jupyter_output><empty_output><jupyter_text>Visualizing the data<jupyter_code>price_property_data.reset_index(inplace=True)
price_property_data = price_property_data.astype(int)
graph = price_property_data.plot.bar(x ='PROPERTYZIP',y='PRICE', title="Distribution of Average Property Sale Prices in Pittsburgh")
plt.axis('off')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07905305432255337, 'fraction_numerical': 0.01077996195307546, 'mean_word_length': 5.646067415730337, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 22, 'https://': 1, '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': '67574', 'license': 'Unlicense', 'n_tokens_mistral': 1330, 'n_tokens_neox': 1275, 'n_words': 553, 'path': "Ethan's Data.ipynb", 'repo_name': 'GrayCleric4/Final-Project', 'size': '4731'}