<jupyter_start><jupyter_text>Visualization<jupyter_code>fig = plt.figure(figsize=(7,10))
ax = fig.add_subplot(212)
ax.hist(df['ratingnh'], bins=50, range=(df['ratingnh'].min(),df['ratingnh'].max()))
plt.title('Rating Distribution with 50 Bins')
plt.xlabel('Rating')
plt.ylabel('Count of Rating')
plt.show()
df.ratingnh.unique()
#Nation-wide distribution of Satisfaction levels for NEIGHBORHOOD?
sns.relplot(x="ratingnh", y='control',data=df)
#filter on 47900: Washington-Arlington-Alexandria, DC-VA-MD-WV|| states only
dmv = df[(df['omb13cbsa'] == 47900)]
#DMV wide distribution of Satisfaction levels for NEIGHBORHOOD?
sns.relplot(x="ratingnh", y="control", data=dmv)
df.omb13cbsa.unique()
#Regression and Residual plot between total household income and neigborhood rating

#tips = sns.load_dataset("ratingnh")
sns.regplot(x="hincp", y="ratingnh", data=df, ci=None)
plt.title("Rating Regression")
plt.xlabel('Total Household Income', size=12)
plt.ylabel('Neighborhood Rating', size=12)
plt.show()

sns.residplot(x="hincp", y="ratingnh", data=df)
plt.title("Rating Residuals")
plt.xlabel('Total Household Income', size=12)
plt.ylabel('Neighborhood Rating', size=12)
plt.show()
# Label the state names
LABEL_MAP = {
    12060: "GA",
    12580: "MD",
    13820: "AL",
    14460: "MA-NH",
    16980: "IL-IN-WI",
    17140: "OH-KY-IN",
    17460: "OH",
    19100: "TX",
    19740: "CO",
    19820: "MI",
    26420: "TX",
    28140: "MO-KS",
    29820: "NV",
    31080: "CA",
    32820: "TN-MS-AR",
    33100: "FL",
    33340: "WI",
    33460: "MN-WI",
    35380: "LA",
    35620: "NY-NJ-PA",
    36420: "OK",
    37980: "PA-NJ-DE-MD",
    38060: "AZ",
    38300: "PA",
    38900: "OR-WA",
    39580: "NC",
    40060: "VA",
    40140: "CA",
    40380: "NY",
    41700: "TX",
    41860: "San Francisco, CA",
    41940: "San Jose-Sunnyvale-Santa Clara, CA",
    42660: "WA",
    45300: "Tampa-St. Petersburg-Clearwater, FL",
    47900: "DC-VA-MD-WV",
    99998: "All other metropolitan areas",
    99999: "Not in a metropolitan area"
}
## Convert state column labels into text
df["omb13cbsa"] = df["omb13cbsa"].map(LABEL_MAP)
df["omb13cbsa"]
f, ax = plt.subplots(figsize=(20,20))
sns.boxplot(x='omb13cbsa', y='ratingnh', data=df, palette='vlag')
sns.swarmplot(x='omb13cbsa', y='ratingnh', data=df, size=2, color='0.3')
plt.title('Rating By State', size=14)
plt.xlabel('State', size=12)
plt.ylabel('Rating', size=12)
plt.show()<jupyter_output><empty_output>