2023-02-01 01:23:45 +00:00
{
"cells": [
{
"cell_type": "markdown",
2023-02-16 00:29:26 +00:00
"metadata": {},
2023-02-01 01:23:45 +00:00
"source": [
2023-02-16 00:29:26 +00:00
"# Nat Scott"
]
2023-02-01 01:23:45 +00:00
},
{
"cell_type": "markdown",
2023-02-16 00:29:26 +00:00
"metadata": {},
2023-02-01 01:23:45 +00:00
"source": [
2023-02-16 00:29:26 +00:00
"## Research question/interests\n",
"\n",
2023-02-16 00:53:33 +00:00
"**Is there a correlation between political alignment & living in neighbourhoods with large quantities of LGBT people?** The obvious answer to this question is \"yes, they are going to mostly be democrats\" but anyone who's ever been around queer people will know that this question is quite a bit more nuanced than that, and this nuance is what we hope to capture in investigating this question.\n",
2023-02-16 00:29:26 +00:00
"\n",
"- The gaybourhoods data set does not include data on residents political alignments, however, there is a wealth of electoral data available freely online that we intend on incorporating into this project. The primary difficulty then will be developing a geographic \"compatibility layer\" between the data sets so that the data can be understood in the same context. To build this, we intend on working with the OpenStreetMap API to create an additional column representing observations position space in a more neutral way, such as their coordinates.\n",
"- Alternatively, we've also considered working with an additional data set that links US zip codes to their longitude and lattitude positions. As such, incorporating this data would be as easy as merging the two tables.\n",
"\n",
"\n",
2023-02-16 00:53:33 +00:00
"**Is there a correlation between geographical stratums & being LGBT?** This question is more abstract, and will serve as a preliminary exploration of the data in hopes of establishing two key details along the way that will shape the rest of the project: how do we quantify queerness, and how do we best represent it visually?\n",
2023-02-16 00:29:26 +00:00
"\n",
"- Once again, representing this data visually will require determining the coordinates associated with each observation.\n",
"- The gaybourhoods data set defines a \"gaybourhood index\" which effectively measures how friendly a given neighbourhood is to queer people. Since this index is entirely subjective, we will need to closely evaluate it's usefulness for our project and investigate different ways to quantify \"queer-friendliness\"\n",
"- In addition to the last point, since, of course, no matter what choice of observations we make, the measurement will still be subjective, answering this research question will come more so in the form of comparing and contrasting different measurements to see what they tell us.\n",
2023-02-16 00:31:05 +00:00
"- Obviously, visualizing this among many aspects of the other research questions would involve projecting the data onto a map of the United States, so visualizing this research question would motivate many of the visualizations for other components of this project"
2023-02-16 00:29:26 +00:00
]
},
2023-02-16 00:53:33 +00:00
{
"cell_type": "code",
2023-03-02 04:25:34 +00:00
"execution_count": 50,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import seaborn as sns"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data Wrangling"
]
},
{
"cell_type": "code",
"execution_count": 76,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>name</th>\n",
" <th>lat</th>\n",
" <th>long</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Hancock OH</td>\n",
" <td>41.000471</td>\n",
" <td>-83.666033</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Stafford VA</td>\n",
" <td>38.413261</td>\n",
" <td>-77.451334</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Webster NE</td>\n",
" <td>40.180646</td>\n",
" <td>-98.498590</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Dimmit TX</td>\n",
" <td>28.423587</td>\n",
" <td>-99.765871</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Cedar IA</td>\n",
" <td>41.772360</td>\n",
" <td>-91.132610</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" name lat long\n",
"0 Hancock OH 41.000471 -83.666033\n",
"1 Stafford VA 38.413261 -77.451334\n",
"2 Webster NE 40.180646 -98.498590\n",
"3 Dimmit TX 28.423587 -99.765871\n",
"4 Cedar IA 41.772360 -91.132610"
]
},
"execution_count": 76,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"## counties - Relating US counties to their long/lat position on the Earth\n",
"counties = pd.read_csv(\"../data/raw/us-county-boundaries.csv\", sep=\";\")\n",
"\n",
"counties = counties.rename({\n",
" \"NAME\": \"name\",\n",
" \"INTPTLAT\": \"lat\",\n",
" \"INTPTLON\": \"long\",\n",
"}, axis=\"columns\")\n",
"\n",
"# Combine the county name with the state code\n",
"def combine_name_state(row):\n",
" row[\"name\"] = f\"{row['name']} {row['STUSAB']}\"\n",
" return row\n",
"\n",
"counties = counties.apply(combine_name_state, axis=\"columns\")\n",
"\n",
"# We don't need this column anymore\n",
"counties = counties.drop([\"STUSAB\"], axis=\"columns\")\n",
"\n",
"counties.to_csv(\"../data/processed/us-county-boundaries.csv\")\n",
"counties.head()"
]
},
{
"cell_type": "code",
2023-03-02 07:42:00 +00:00
"execution_count": 107,
2023-03-02 04:25:34 +00:00
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>party</th>\n",
" <th>votes</th>\n",
" <th>total</th>\n",
" <th>percent</th>\n",
" <th>lat</th>\n",
" <th>long</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Democrat</td>\n",
" <td>6363</td>\n",
" <td>23932</td>\n",
" <td>0.265878</td>\n",
" <td>32.532237</td>\n",
" <td>-86.646439</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Republican</td>\n",
" <td>17379</td>\n",
" <td>23932</td>\n",
" <td>0.726183</td>\n",
" <td>32.532237</td>\n",
" <td>-86.646439</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Other</td>\n",
" <td>190</td>\n",
" <td>23932</td>\n",
" <td>0.007939</td>\n",
" <td>32.532237</td>\n",
" <td>-86.646439</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Democrat</td>\n",
" <td>18424</td>\n",
" <td>85338</td>\n",
" <td>0.215894</td>\n",
" <td>30.659218</td>\n",
" <td>-87.746067</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Republican</td>\n",
" <td>66016</td>\n",
" <td>85338</td>\n",
" <td>0.773583</td>\n",
" <td>30.659218</td>\n",
" <td>-87.746067</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
2023-03-02 07:42:00 +00:00
" party votes total percent lat long\n",
"0 Democrat 6363 23932 0.265878 32.532237 -86.646439\n",
"1 Republican 17379 23932 0.726183 32.532237 -86.646439\n",
"2 Other 190 23932 0.007939 32.532237 -86.646439\n",
"3 Democrat 18424 85338 0.215894 30.659218 -87.746067\n",
"4 Republican 66016 85338 0.773583 30.659218 -87.746067"
2023-03-02 04:25:34 +00:00
]
},
2023-03-02 07:42:00 +00:00
"execution_count": 107,
2023-03-02 04:25:34 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"## pol - Election results from the 2012 American presidential election\n",
"pol = pd.read_csv(\"../data/raw/countypres_2000-2020.csv\")\n",
"\n",
"# We only want 2012--the latest election before the gb data was collected\n",
"\n",
"pol = pol[pol[\"year\"] == 2012].reset_index()\n",
"\n",
"# Get rid of undesireable columns\n",
"pol = pol.drop([\n",
" \"year\", \"state\", \"county_fips\", \"office\",\n",
" \"candidate\", \"version\", \"mode\", \"index\",\n",
"], axis=\"columns\")\n",
"\n",
"# Change the column names to make them a little more friendly\n",
"pol.rename({\n",
" \"county_name\": \"county\",\n",
" \"state_po\": \"state\",\n",
" \"candidatevotes\": \"votes\",\n",
" \"totalvotes\": \"total\"\n",
"}, axis=\"columns\", inplace=True)\n",
"\n",
"# Make cells lowercase\n",
"pol[\"county\"] = pol[\"county\"].apply(lambda x: x.capitalize())\n",
"pol[\"party\"] = pol[\"party\"].apply(lambda x: x.capitalize())\n",
"\n",
"# Combine the county name with the state code\n",
"def combine_name_state(row):\n",
" row[\"county\"] = f\"{row['county']} {row['state']}\"\n",
" return row\n",
"\n",
"pol = pol.apply(combine_name_state, axis=\"columns\")\n",
"\n",
"# Add a percent column which will be useful when graphing\n",
"pol[\"percent\"] = pol[\"votes\"] / pol[\"total\"]\n",
"\n",
"# Attach long/lat data to each row\n",
"pol = pol.merge(counties, left_on=\"county\", right_on=\"name\")\n",
"\n",
"# Now we can get rid of the state columns\n",
2023-03-02 07:42:00 +00:00
"pol = pol.drop([\"state\", \"name\", \"county\"], axis=\"columns\")\n",
2023-03-02 04:25:34 +00:00
"\n",
"pol.to_csv(\"../data/processed/election-2012.csv\", index=False)\n",
"pol.head()"
]
},
{
"cell_type": "code",
"execution_count": 87,
2023-02-16 00:53:33 +00:00
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Tax_Mjoint</th>\n",
" <th>TaxRate_SS</th>\n",
" <th>TaxRate_FF</th>\n",
" <th>TaxRate_MM</th>\n",
2023-03-02 04:25:34 +00:00
" <th>Cns_RateSS</th>\n",
" <th>Cns_RateFF</th>\n",
" <th>Cns_RateMM</th>\n",
" <th>CountBars</th>\n",
2023-02-16 00:53:33 +00:00
" <th>FF_Index</th>\n",
" <th>MM_Index</th>\n",
" <th>SS_Index</th>\n",
" <th>TOTINDEX</th>\n",
2023-03-02 04:25:34 +00:00
" <th>lat</th>\n",
" <th>long</th>\n",
2023-02-16 00:53:33 +00:00
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>2120</td>\n",
" <td>203.301887</td>\n",
" <td>28.773585</td>\n",
" <td>174.528302</td>\n",
2023-03-02 04:25:34 +00:00
" <td>77.125329</td>\n",
" <td>6.931719</td>\n",
" <td>70.193610</td>\n",
" <td>15</td>\n",
2023-02-16 00:53:33 +00:00
" <td>6.724415</td>\n",
" <td>48.288254</td>\n",
" <td>55.012669</td>\n",
" <td>67.077054</td>\n",
2023-03-02 04:25:34 +00:00
" <td>34.093828</td>\n",
" <td>-118.381697</td>\n",
2023-02-16 00:53:33 +00:00
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>5080</td>\n",
" <td>205.511811</td>\n",
" <td>33.464567</td>\n",
" <td>172.047244</td>\n",
2023-03-02 04:25:34 +00:00
" <td>88.478367</td>\n",
" <td>15.617404</td>\n",
" <td>72.860963</td>\n",
" <td>17</td>\n",
2023-02-16 00:53:33 +00:00
" <td>9.834048</td>\n",
" <td>48.578469</td>\n",
" <td>58.412517</td>\n",
" <td>61.866815</td>\n",
2023-03-02 04:25:34 +00:00
" <td>37.758057</td>\n",
" <td>-122.435410</td>\n",
2023-02-16 00:53:33 +00:00
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>5790</td>\n",
" <td>107.772021</td>\n",
" <td>16.753022</td>\n",
" <td>91.018998</td>\n",
2023-03-02 04:25:34 +00:00
" <td>46.771050</td>\n",
" <td>5.745582</td>\n",
" <td>41.025469</td>\n",
" <td>5</td>\n",
2023-02-16 00:53:33 +00:00
" <td>4.370779</td>\n",
" <td>26.360413</td>\n",
" <td>30.731192</td>\n",
" <td>37.908747</td>\n",
2023-03-02 04:25:34 +00:00
" <td>40.742039</td>\n",
" <td>-74.000620</td>\n",
2023-02-16 00:53:33 +00:00
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>3510</td>\n",
" <td>80.056980</td>\n",
" <td>21.082621</td>\n",
" <td>58.974359</td>\n",
2023-03-02 04:25:34 +00:00
" <td>31.619291</td>\n",
" <td>9.315448</td>\n",
" <td>22.303843</td>\n",
" <td>10</td>\n",
2023-02-16 00:53:33 +00:00
" <td>6.055939</td>\n",
" <td>15.939869</td>\n",
" <td>21.995808</td>\n",
" <td>37.530067</td>\n",
2023-03-02 04:25:34 +00:00
" <td>40.734012</td>\n",
" <td>-74.006746</td>\n",
2023-02-16 00:53:33 +00:00
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>2660</td>\n",
" <td>91.353383</td>\n",
" <td>12.781955</td>\n",
" <td>78.571429</td>\n",
2023-03-02 04:25:34 +00:00
" <td>21.763042</td>\n",
" <td>3.142678</td>\n",
" <td>18.620365</td>\n",
" <td>9</td>\n",
2023-02-16 00:53:33 +00:00
" <td>3.004058</td>\n",
" <td>18.280165</td>\n",
" <td>21.284224</td>\n",
" <td>35.843573</td>\n",
2023-03-02 04:25:34 +00:00
" <td>37.773134</td>\n",
" <td>-122.411167</td>\n",
2023-02-16 00:53:33 +00:00
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
2023-03-02 04:25:34 +00:00
" Tax_Mjoint TaxRate_SS TaxRate_FF TaxRate_MM Cns_RateSS Cns_RateFF \\\n",
"0 2120 203.301887 28.773585 174.528302 77.125329 6.931719 \n",
"1 5080 205.511811 33.464567 172.047244 88.478367 15.617404 \n",
"2 5790 107.772021 16.753022 91.018998 46.771050 5.745582 \n",
"3 3510 80.056980 21.082621 58.974359 31.619291 9.315448 \n",
"4 2660 91.353383 12.781955 78.571429 21.763042 3.142678 \n",
2023-02-16 00:53:33 +00:00
"\n",
2023-03-02 04:25:34 +00:00
" Cns_RateMM CountBars FF_Index MM_Index SS_Index TOTINDEX \\\n",
"0 70.193610 15 6.724415 48.288254 55.012669 67.077054 \n",
"1 72.860963 17 9.834048 48.578469 58.412517 61.866815 \n",
"2 41.025469 5 4.370779 26.360413 30.731192 37.908747 \n",
"3 22.303843 10 6.055939 15.939869 21.995808 37.530067 \n",
"4 18.620365 9 3.004058 18.280165 21.284224 35.843573 \n",
2023-02-16 00:53:33 +00:00
"\n",
2023-03-02 04:25:34 +00:00
" lat long \n",
"0 34.093828 -118.381697 \n",
"1 37.758057 -122.435410 \n",
"2 40.742039 -74.000620 \n",
"3 40.734012 -74.006746 \n",
"4 37.773134 -122.411167 "
2023-02-16 00:53:33 +00:00
]
},
2023-03-02 04:25:34 +00:00
"execution_count": 87,
2023-02-16 00:53:33 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
2023-03-02 04:25:34 +00:00
"## gb - the gaybourhoods dataset\n",
"gb = pd.read_csv(\"../data/raw/gaybourhoods.csv\")\n",
"cords = pd.read_csv(\"../data/raw/zip_lat_long.csv\")\n",
"\n",
"# Let's add long/lat columns to gb\n",
"gb = gb.merge(cords, left_on=\"GEOID10\", right_on=\"ZIP\")\n",
"\n",
"# Get rid of unneeded columns\n",
"gb = gb.drop([\n",
" \"Mjoint_MF\", \"Mjoint_SS\", \"Mjoint_FF\", \"Mjoint_MM\",\n",
" \"Cns_TotHH\", \"Cns_UPSS\", \"Cns_UPFF\", \"Cns_UPMM\",\n",
" \"ParadeFlag\", \"FF_Tax\", \"FF_Cns\", \"MM_Tax\", \"MM_Cns\",\n",
" \"SS_Index_Weight\", \"Parade_Weight\", \"Bars_Weight\",\n",
" \"GEOID10\", \"ZIP\",\n",
"], axis=\"columns\")\n",
"\n",
"# There's a lot of info baked into some of these columns. Especially the composite indexes.\n",
"# We'll leave their names as is for easy reference even if they're a little ugly.\n",
"gb = gb.rename({\n",
" \"LAT\": \"lat\",\n",
" \"LNG\": \"long\",\n",
"}, axis=\"columns\")\n",
2023-02-16 00:53:33 +00:00
"\n",
2023-03-02 04:25:34 +00:00
"gb.to_csv(\"../data/processed/gaybourhoods-nat.csv\")\n",
"gb.head()"
2023-02-16 00:53:33 +00:00
]
2023-03-02 07:42:00 +00:00
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exploratory Data Analysis\n",
"\n",
"In the previous section we got a pretty good idea of what the data looks like and managed to condense it to fewer key variables that will be useful when answering the research questions established above. Now, we will compare these variables, attempt to create some plots, and see if we can't uncover any interesting relationships that aren't evident by looking at the numbers alone.\n",
"\n",
"Let's start with a scatterplot of the `gb` data set. I have no idea what this is going to look like. Let's see:"
]
},
{
"cell_type": "code",
"execution_count": 109,
"metadata": {},
"outputs": [
{
"data": {
2023-03-03 09:13:54 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjIAAAHHCAYAAACle7JuAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAABpOklEQVR4nO3deVhUZf8G8Hv2YYAZYAYEFBEdFDeS1EoBM9c3NXPp16Ll2vamWfZWSq+5VKbtWqRppVlpq9lipWlmqWWvKe5LYu7iAsIMwzD78/uDmBhBRASGwftzXVw65zxz5jtnhpmb5zzPORIhhAARERFRAJL6uwAiIiKi6mKQISIiooDFIENEREQBi0GGiIiIAhaDDBEREQUsBhkiIiIKWAwyREREFLAYZIiIiChgMcgQERFRwGKQoQp1794d3bt393cZV5X169dDIpFg/fr1/i7FxwcffICkpCQoFAqEhYVd9v2PHDkCiUSCl19+ueaLq2dKX8PPP//c36X4mD59OiQSCXJzc/1dildtf8bU198nqnkMMgHsvffeg0QigVqtxsmTJ8ut7969O9q1a+eHyqrP4/Hg/fffx/XXX4+IiAiEhoaiZcuWGDFiBDZv3lwrj2m1WjF9+vQKP/C+++47TJ8+vVYetybVVp379+/HqFGj0KJFC7z99ttYuHBhnddwuex2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jMzERCQgJWrFiBxx9/HK1bt0bPnj19utyXL1+Oa665BoMHDy6
2023-03-02 07:42:00 +00:00
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plot_naive_scatter1 = sns.scatterplot(data=gb, x=\"long\", y=\"lat\")\n",
"_ = plot_naive_scatter1.set(\n",
" xlabel=\"Longitude\",\n",
" ylabel=\"Latitude\",\n",
" title=\"Naive Scatteplot of the Gaybourhoods data set\"\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here the data does appear to trace the outline of the United States, probably because most of the cities the data set covers are along the coast. We can do something similar with the election data we cleaned earlier:"
]
},
{
"cell_type": "code",
"execution_count": 108,
"metadata": {},
"outputs": [
{
"data": {
2023-03-03 09:13:54 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlAAAAHHCAYAAABwaWYjAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOx9e3wTVfr+k0yTJm16swqCVhAqlEukX8AWpRVWQcCy2ip4Aa1isawLUhfkZnGVpYDgDRRUqixuWVgRXJAVisK6rsB6AwRBpIIK1h8oWntLmzTTyfz+SM70zGRuKSBoz/P5+JHOTGbOnExynrzv8z6vRRRFEQwMDAwMDAwMDKZhPdcDYGBgYGBgYGD4tYERKAYGBgYGBgaGCMEIFAMDAwMDAwNDhGAEioGBgYGBgYEhQjACxcDAwMDAwMAQIRiBYmBgYGBgYGCIEIxAMTAwMDAwMDBECEagGBgYGBgYGBgiBCNQDAwMDAwMDAwR4jdHoAYPHozBgwef62G0Kbz33nuwWCx47733zvVQZFi1ahXS0tJgs9mQmJh4rodz3uDee+9F586dZdssFgsef/xx6e9XX30VFosFx44d+0XHtnXrVqSnp8PhcMBisaCmpuYXvf6ZwLFjx2CxWPD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QtiYmJwww03oLKyEqIoYu7cubj00kvhdDpx88034+eff9adH7PPbmlpKbp27Yro6GhcddVV+OSTT8KOOXz4MEaNGoULLrgADocD/fv3x6ZNm3SvDwCXX365jDyRseTm5qKpqQlff/21tH39+vXgOA6FhYXSNofDgYKCAnzwwQeorKyUtnfs2NHUIt2vXz8ZeQKA5ORkZGdn44svvjB8vRauu+46AMHvVSA41y6XC1999RVuvPFGxMXFST9ozH6X7d69G8OGDcOFF14Ip9OJyy+/HPfdd5/sGLXviZ07d+Kqq66Cw+FA165dsXz5cs1x//3vf5e+7y644ALccccdsnkFWp7lQ4cO4Xe/+x1iYmJwySWXYNGiRdIx7733Hq666ioAwLhx48LS82q6o6eeegrXXHMNkpOT4XQ60a9fP6xfv15nls8ezL4nQPD7ZNCgQYiLi0N8fDyuuuoqrFmzBkBwrjZv3ozjx49Lc0DuW0sD9e6770rfT4mJibj55pvDnkWiYTt69CjuvfdeJCYmIiEhAePGjUNjY2NE93pOI1CXX3458vPz8fLLL2PmzJm6UagXX3wRvXr1wk033YSoqCj861//wh//+EcEAgFMnDhR9TXt27fHoEGD8Prrr0sLKsHatWvBcZy02DU2NmLQoEH4f//v/2HChAm47LLL8L///Q+zZs3CyZMndfOw5Ets3bp1GD16tO4vY4/HI33B3Hfffejbty9++uknbNq0Cd999x0uvPBC1NXV4ZVXXsGdd96J+++/H/X19VixYgWGDRuGjz/+GOnp6bjooovw4osv4oEHHkBeXh5uueUWAEFNT0NDA06cOIFt27Zh1apVYWOYMGECXn31VYwbNw6TJ0/GN998g6VLl+LTTz/Frl27ZF+eR44cwe23344//OEPuOeee7By5UqMHj0aW7duxdChQzXvk5z/qquuwoIFC/DDDz9gyZIl2LVrFz799FMkJiZiwoQJuuNUw+OPP445c+ZgyJAheOCBB1BRUYEXX3wRn3zyiTT2xYsXo6ysDBs2bMCLL74Il8uFK6+8UvOcY8eORWFhId5++22MHDlS2n7gwAEcPHgQf/7znwEAn3/+ObKzsxEfH4/p06fDZrNh+fLlGDx4MP773/8iMzMT1157LSZPnoznnnsOjzzyCHr06AEA0v9XrVqFe+65B8OGDcPChQvR2Ni
2023-03-02 07:42:00 +00:00
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plot_naive_scatter2 = sns.scatterplot(data=pol, x=\"long\", y=\"lat\")\n",
"_ = plot_naive_scatter2.set(\n",
" xlabel=\"Longitude\",\n",
" ylabel=\"Latitude\",\n",
" title=\"Naive Scatteplot of Vote Tallies from the 2012 Presidential Election\"\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This plot looks a little weird, which probably has to do in part with the fact that we are very thoughtlessly trying to project a portion of a geoid onto a cartesian plane using a measurement that is not cartesean coordinates\n",
"\n",
"Another issue with these plots is the fact that the data is very messy. It's not all that meaningful for more reasons than just the fact that it's messy, but being messy doesn't help all that much\n",
"\n",
"One thing that stands out is the outliers in the bottom left of the plot, which is clearly Hawaii. Hawaii is not covered by the Gaybourhoods data set at all so we can remove these rows like so:"
]
},
{
"cell_type": "code",
"execution_count": 111,
"metadata": {},
"outputs": [
{
"data": {
2023-03-03 09:13:54 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlAAAAHHCAYAAABwaWYjAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOx9e3wU1fn+s7vZzW5uJEZBKDEKEcIlkgICSiJWQUCoJgWsgkQRDb8WJBYFxOCFEq6CgooKSrFQqAgtSJWL0NYL1LuCIBJFBeMXBA0Jue1mN7Pz+2P3TM6cOXPbbEjQeT4fP5Ld2bnPnOe87/M+r00URREWLFiwYMGCBQsWDMPe0jtgwYIFCxYsWLBwvsEiUBYsWLBgwYIFCyZhESgLFixYsGDBggWTsAiUBQsWLFiwYMGCSVgEyoIFCxYsW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OTk50nIbNmzAxo0b0bt3b3To0EF1+y+++CJWr16NUaNG4Y9//CPOnj2LlStXYsCAAdi5c6fha/jnP/8Zl112GXw+H/bu3YvnnnsO27dvx6FDhxAXFxfZyYkAXq/X8DPe3Dhx4gTmzJmDSy+9FNnZ2bLvXnjhBQSDwWbfhyFDhqCgoEDxeZcuXZp92wQbNmzAoUOHcN9998k+T09Ph9frhdPpPGf7wkOL3i3Z2dl44YUXMGvWLM0H1QxcLldU1mMGp06dwrPPPot77rlHEelYtmwZfvzxx3O+T790nD59GgB0U3djx47FrFmzsGHDBi6B+vvf/w5RFDFu3Ljm2E3DyMvLk/39ww8/4O9//zvy8vKaJYTucDjgcDiivl4tGL1mQGjycC4H19aIHj164KuvvkJ6err02R//+EcMHjwYixYtwowZM6QI3gcffICXX34Zjz/+OB544AEAQEFBAXr27IkZM2bgf//7n7SO+fPn44UXXoDT6cTIkSNx6NAh7vZvu+02PPbYY0hISJA+u+uuu9CtWzc89thjhgnU8OHD0bdvXwDA3XffjdTUVDzxxBN49dVXcdttt3F/U1tbG/XopNvtjur6mgvnijR06dIFt99++znZllmQiGVLo0U1UA899BAEQcDChQt1l12zZg2uu+46tG3bFrGxsejevTuee+45xXK0BurUqVOIiYlRzMQAoLS0FDabDc8884z0WWVlJe677z6kpaUhNjYWGRkZWLRokS7b//bbbyGKIgYOHKj4zmazoW3btrLPKisr8ac//QmXXnopYmNj0bFjRxQUFOCnn34CAPj9fjzyyCPo06cP2rRpg/j4eOTm5uK///2vtI5jx47hoosuAgDMmTNHCq8+9thjuPPOO7FixQpp++Q/gmAwiGXLlqFHjx5wu91o164dJk2ahIqKCtl+XnrppRg5ciTeeOMNSZfSvXt3/POf/9Q8HwSbNm1Cnz594PF4cOGFF+L222+XpWz19lMNzz77LHr06IHY2Fh06NABkydPlmllLr30Ujz66KMAgIsuukhT25CWloZrrrkGmzdvRiAQUHy/YcMGdO7cGf379wcAfPrppxg+fDiSkpKQkJCA66+/XpaifemllzBmzBgAwG9+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X7/+9/j//2//4c77rgDa9aswZgxY7Bz504MGTJE9TjJ+q+88kosWLAAp06dwvLly7Fv3z58+umnSE5OxqRJkzT3k4fHHnsMc+bMweDBg/GHP/wBpaWleO655/Dhhx9K+75s2TKsXbsWW7ZswXPPPYeEhARcccUVquscN24cCgsLsWvXLowcOVL6/ODBgzh06BAeeeQRAMDnn3+O3NxcJCUlYcaMGXA6nVi5ciWuvfZavPXWW+jfvz+uueYaTJ06FU899RQeeughdOvWDQCk/69btw5
2023-03-02 07:42:00 +00:00
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"pol = pol[pol[\"long\"] > -140]\n",
"\n",
"plot_naive_scatter3 = sns.scatterplot(data=pol, x=\"long\", y=\"lat\")\n",
"_ = plot_naive_scatter3.set(\n",
" xlabel=\"Longitude\",\n",
" ylabel=\"Latitude\",\n",
" title=\"Naive Scatteplot of Vote Tallies from the 2012 Presidential Election\"\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 116,
"metadata": {},
"outputs": [
{
"data": {
2023-03-03 09:13:54 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkkAAAJOCAYAAACjhZOMAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9eZBtyV3fi34z17TnXeOZhx7O6UFDS7RAahkJCxDDxXBlobAdQtd2cLn2s59MIBGOp2eHDTaPMPiPa4h7DQ4ewcX3RSCwsbkYXzBgBgkEatR0t9SSejp95rFOVe15WGPm+yP32rX3rjXkPmfXqTrn/D4RHdKpylqZK1eulb+VK3/fL5NSShAEQRAEQRBT8P1uAEEQBEEQxEGEgiSCIAiCIIgEKEgiCIIgCIJIgIIkgiAIgiCIBChIIgiCIAiCSICCJIIgCIIgiAQoSCIIgiAIgkiAgiSCIAi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slOvTZBJHGp5cOPJB5dtlGy0uu+0Q2xNQhxomZhtZT+eBgGAm1PoGgy1BxOjuMEQTyQkATAPiCkRNsV6Hhi/DPOgOWCgbLNxhOOlBL9QAUpYuIqVR2OpYzAJotoFPT0g50DGgxYLRkoTkyeUkp0PYGWKxCXZADqBX7Hk+IwEHir4aHl7px32eI4u2qj6hjjn6X2T9FA2WIHYkIWUuJ6J8DlVjDuH86AR5ZsHKtOBzbDQGB7ECGauIZli2G5OB34DQKBt7Y9tCfOu2Kr/qnYO/0TCokrLR/Xu+H4ZyYHHl9xsF4ypsbPRj/EhYY/VffJmoWTdWuq7o4X4dy2h8HEuFgpGnh8xZ4K6OKgebKcyYHVooFCSvBFEMS94SDOd/c
2023-03-02 07:42:00 +00:00
"text/plain": [
"<Figure size 600x600 with 3 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# A prettier way to represent the number of observations in a given region\n",
"# would be to use a hexbin plot:\n",
"plot_naive_hexbin = sns.jointplot(data=pol, x=\"long\", y=\"lat\", kind=\"hex\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There are quite a few counties concentrated around the east coast, above Florida and below New Hampshire. On the other hand, there are far fewer individual counties along the west coast. This is all pretty self-evident."
]
},
{
"cell_type": "code",
"execution_count": 125,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Number of data points in the region of New York: 131\n"
]
},
{
"data": {
2023-03-03 09:13:54 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkAAAAHHCAYAAABXx+fLAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAACw20lEQVR4nOzdd5xU1fk/8M+t08v2wvaFZeldRBFREDB8UUBjiQ01UaOxhGjUFCM2NBrF2GPyMxpNTDSxRCOKFQsiRXqHpS7by+z0ufee3x/L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NYxMmTGBPPPEEu/fee5nRaGSnnHJKxOtOmjSJPfHEE+yuu+5iBoMh7DWwYsUKJooiKysrY7///e+Dr5WUlJSQPm3atIkZDAZWUFDAli5dyu6//36WlZXFRo8eHfK8tmzZwmRZZhMnTmRPPvkke/7559ntt9/Opk2bFvbcT1ZYWMiuuuqqsOcwbtw4dvbZZ7OnnnqK/eIXv2CCILCLLrqow+u1/cxra2vZ2WefzbKyspjb7Q6539y5c0Me8+Mf/5iJosh+8pOfsOeff57deeedzGQysUmTJjG/388YY+w///kPAxDyOhgzZgzjeZ5deOGFwWNvvPEGA8C2bNnSYV/nzp3LUlJS2N69e1l+fj477bTTmKZpTNM0dvbZZzOO49iPf/xj9vTTT7N58+YxAOy2224LuQYANmzYMJaRkcGWLFnCnnnmGfb999+ziooKBoA9+uijjDHGFEVhV155JdPpdOy9995rt1+/+tWvGAC2cuXKDp8DY+Gv87/97W9Mp9OxM844g/3tb39jf/vb39g333zDNE1j+fn57IILLgi7xg9+8ANWWlraqfuR2KIAiMRVU1MTA8DOP//8ds8777zzGADmcDgYY50PgPbv388EQWAPPvhgyHmbN29moigGj2uaxoYMGcJmz57NNE0Lnud2u1lxcTE755xzwu5x6aWXduo5nhgANTU1sZSUFHbeeecF208OgFpaWpjdbmc/+clPQq5TVVXFbDZbyPGTn++6desifhgsWrQoagB0zTXXhJy7YMEClpaWFnIMAAPA1q5dGzx24MABptfr2YIFC4LH5s+fz2RZZnv37g0eq6ysZBaLJeRDv6sBEAC2fPnykHPbfq7Dhg1jPp8vePzJJ58M+UD2+/0sMzOTjRw5knk8nuB57733HgPA7rnnnuCxsWPHsszMTFZfXx88tnHjRsbzPLvyyitDnqder2cHDhwIHtu2bRsTBCHkeT3xxBPBoKOrogVAM2fODHmN/vznP2eCILCmpqZ2r3diAPTFF18wAOzxxx8Pud+JAdCXX37JALDXXnst5DrLly8POV5TU8MAsGeffZYx1vo3zfM8++EPf8iysrKCj7vllltYampqSN+j2b9/PzOZTCw1NZVJkhT8Xb799tsMAHvggQdCzr/wwgsZx3Fsz549wWMAGM/zbOvWrSHnnhgABQIBdvHFFzODwcA+/PDDDvu1YMECBiAkaG5PpNe5yWQK+b22ufvuu5lOpwv5PdbU1DBRFEP+bknvoSkwElctLS0AAIvF0u55be1t53fWf/7zH2iahosuugh1dXXB/7KzszFkyBB89tlnAIANGzZg9+7d+NGPfoT6+vrgeS6XCzNmzMDKlSuhaVrItW+44YYu9QVoHeK/7bbb8O677+L777+PeM6KFSvQ1NSESy+9NKTPgiBg8uTJwT5H0jbEf+ONN4Ycv/nmm6M+5uTnccYZZ6C+vh4OhyPk+JQpUzBhwoTgvwsKCnD++efjww8/hKqqUFUVH330EebPn4+SkpLgeTk5OfjRj36Er776KuyanVVcXIzZs2dHbLv
2023-03-02 07:42:00 +00:00
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# New York is one of the cities covered by the Gaybourhoods data set.\n",
"# Let's take a closer look at it:\n",
"\n",
"gb_ny = gb[gb[\"long\"] > -73]\n",
"print(f\"Number of data points in the region of New York: {gb_ny.shape[0]}\")\n",
"plot_ny_scatter1 = sns.scatterplot(data=gb_ny, x=\"long\", y=\"lat\", hue=\"TOTINDEX\")\n",
"_ = plot_ny_scatter1.set(\n",
" xlabel=\"Longitude\",\n",
" ylabel=\"Latitude\",\n",
" title=\"Queer Neighbourhoods in New York City\"\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the above plot, we colour points darker the higher their \"gaybourhood index\" is. This index is a weighted composite of a few factors. The TOTINDEX boldy weighs the queerness of same-sex married couples more than unmarried same-sex households. While it's subjective, in my opinion, this marginalizes the experiences of queer people who have no desire to marry.\n",
"\n",
"If we wanted to look at unmarried same sex households alone, we could use the \"Cns_RateSS\" column:"
]
},
{
"cell_type": "code",
"execution_count": 126,
"metadata": {},
"outputs": [
{
"data": {
2023-03-03 09:13:54 +00:00
"image/png": "iVBORw0KGgoAAAANS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HesrKyMGAwGvw/9jgZAAMiqVav8zm35vQ4ZMoS43W7f8RdffNHvA9nj8ZC4uDhSUFBAnE6n77wvvviCACCPPPKI79jIkSNJXFwcqa2t9R3bsWMHYVmW3HTTTX6PU61Wk+LiYt+xvXv3Eo7j/B7XCy+84As6OipUADRjxgy/5+i9995LOI4jDQ0NrV7v9ABo/fr1BAB5/vnn/e7v9ABo48aNBAB5//33/a6zatUqv+NVVVUEAFm+fDkhpPk1zbIsufLKK0l8fLzvdnfddReJiory63soRUVFRKfTkaioKKJSqXx/y08//ZQAIIsXL/Y7/4orriAMw5DDhw/7jgEgLMuSPXv2+J17egDk9XrJ1VdfTTQaDVm9enWb/Zo3bx4B4Bc0tybY81yn0/n9XVs8/PDDRBRFv79jVVUV4Xne73VL9Rw6BUZ1q6amJgCAwWBo9byW9pbz2+vjjz+Goii46qqrUFNT4/tJSEhATk4O1q1bBwDYvn07Dh06hOuuuw61tbW+8+x2O6ZPn44NGzZAURS/a99+++0d6gvQPMR/zz33YOXKldi2bVvQc9asWYOGhgZce+21fn3mOA5nnXWWr8/BtAzx33HHHX7H77zzzpC3OfNxTJ48GbW1tbBarX7HJ0yYgDFjxvj+n5aWhksuuQSrV6+GLMuQZRlff/01Lr30UmRlZfnOS0xMxHXXXYfvv/8+4JrtlZmZiVmzZgVtu+WWWyAIgl//AeDo0aM
2023-03-02 07:42:00 +00:00
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plot_ny_scatter2 = sns.scatterplot(data=gb_ny, x=\"long\", y=\"lat\", hue=\"Cns_RateSS\")\n",
"_ = plot_ny_scatter2.set(\n",
" xlabel=\"Longitude\",\n",
" ylabel=\"Latitude\",\n",
" title=\"Queer Neighbourhoods in New York City\"\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As predicted, the diversity of the data becomes more apparent when we don't hide it. While the difference isn't extremely substantial, it will be worthwhile to continue to analyze multiple factors when exploring this data. This is especially the case when we consider the fact that the data set is already very limited in how it fails to account for gender diversity.\n",
"\n",
"Just for fun, let's do something similar for the political dataset:"
]
},
{
"cell_type": "code",
"execution_count": 129,
"metadata": {},
"outputs": [
{
"data": {
2023-03-03 09:13:54 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkQAAAHHCAYAAABeLEexAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOyddXgc17n/P7uzzGJmW5YlGWRmdmzHAYccaPCG2pTTW/7d26TtLbdJkwbaFNJw4pDDcew4ZmYZZFsWM6+W6fz+WGul9a5k2UnqwH6ex89jDZw5c2Z25jvveUEmhBDEiBEjRowYMWJ8iZFf6A7EiBEjRowYMWJcaGKCKEaMGDFixIjxpScmiGLEiBEjRowYX3pigihGjBgxYsSI8aUnJohixIgRI0aMGF96YoIoRowYMWLEiPGlJyaIYsSIESNGjBhfemKCKEaMGDFixIjxpScmiGLEiBEjRowYX3pigijGp8J7773H+PHj0Wg0yGQyuru7L3SXyM3N5dZbb73Q3fjM8uSTTyKTyaiurv7E2qyurkYmk/Hkk09+Ym1+mvT19w9/+MOF7spnhvvuuw+ZTHahu/Glpu+3uXv37gvdlS80n3lB1Hcj9P3TaDQUFhbyjW98g5aWlgvdvY/NkSNHuO+++z7Rl9CFpqOjg5UrV6LVannkkUd4+umn0ev1/5Fjb926lfvuu+8zIcC+TDz33HM8+OCDF7obX1oaGxu577772L9//wXrw6233hr2rDYYDOTn53P11VfzyiuvEAgELljfPms4HA7uu+8+Pvroowvdlc8Vn/bzXfGptPop8POf/5y8vDxcLhebN2/mscce45133qG8vBydTnehu3feHDlyhPvvv5958+aRm5t7obvzibBr1y56e3v5xS9+waJFi/6jx966dSv3338/t956KxaLJWxdRUUFcvln/hvgc8lzzz1HeXk53/nOd8KW5+Tk4HQ6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iugXIH72s59FjMfA4wznHlyzZo0YP368SExMDI35a6+9Nujxz/Ucy8rKxJVXXikeffRRcccddwhA/OAHPxhyzPfu3SsA8eabb4aWXX755UIul4tJkyaFlu3atUsA4q233grrb1lZmRgxYoT47W9/K373u9+JxMREkZmZGfYbH+55RGPBggWiuLg4Yvn9998vJEkK3RPNzc0iJSVFGI1G8dOf/lT86U9/EuPGjRNyuVy8+uqroW1+/vOfC0DcddddoWtQWVkphBBi3bp1QqVSienTp4s//vGP4oEHHhBjx44VKpVK7NixI3TsgwcPCq1WK7Kzs8Wvf/1r8Ytf/EKkpKSIsWPHiuG8Km655Rah1+sHXf/0008LQPzlL38JLXvqqaeETCYTS5cuFQ8//LD47W9/K3Jzc4XFYgkbw1tuuUVoNBpRXFwsvvrVr4pHHnlEzJgxI3Rvpaeni+9///vi4YcfFiUlJUKSJHHq1KnQ/sMZRyHEsN4DffdIcXGxyM/PF7/5zW/EAw88IGpqakRbW5tIS0sT9957r3jsscfE7373OzFq1CihVCrFvn37hBBC2Gw28dhjjwlAXHHFFaHrdeDAgUHHru+3OWbMmNBz/utf/7qQy+Vizpw5IhAICCGC9+SZ970QQjQ1NQlJksTPf/7zIa/hmjVrhEqlEjk5OeJnP/uZeOyxx8S3vvUtsWjRotA2w73vb7nlFpGTkxNxjL7f9UAAMW7cOJGWliZ+8YtfiAcffFDk5+cLnU4n2tvbhRBDP9+feOIJAYhDhw6Ftbtz504BiKeeemrI8w71Y1hbXUD6boS1a9eKtrY2UVdXJ1544QWRkJAgtFqtqK+vF9XV1UKSJPF///d/YfseOnRIKBS
2023-03-02 07:42:00 +00:00
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plot_democrat_scatter = sns.scatterplot(\n",
" data=pol[pol[\"party\"] == \"Democrat\"],\n",
" x=\"long\",\n",
" y=\"lat\",\n",
" hue=\"percent\"\n",
")\n",
"_ = plot_democrat_scatter.set(\n",
" xlabel=\"Longitude\",\n",
" ylabel=\"Latitude\",\n",
" title=\"Percentage of voting population who voted Democrat by county\"\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A better way to represent this data would be to use a heatmap, but even this scatterplot reveals something we probably already knew: Democrats tend to be concentrated around the urban parts of the United States"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Renewed Analysis Plan\n",
"\n",
"The research questions posed earlier in this analysis still feel sufficiently specific, having clear, measurable goals and room for additional analysis. Here are two very rough step-by-step plans to answer the two research questions I seek to answer in this analysis:\n",
"\n",
"**Is there a correlation between political alignment & living in neighbourhoods with large quantities of LGBT people?**\n",
"1. Unify the political data with the gaybourhoods data set\n",
" 1. Establish the best way to measure the distance from a given `gb` and a county (Euclidean distance? Some other measurement?)\n",
" 2. Find the county that is closest to each observation by minimizing the function established in step (a)\n",
" c. Merge the two tables. Each `gb` observation should then include a political breakdown of the nearest county during the 2012 presidential election\n",
"2. Use this information to plot queerness by different metrics against political alignment and measure the correlation\n",
"\n",
"**Is there a correlation between geographical stratums & being LGBT?**\n",
"1. Explore different metrics of queerness and analize more qualitatively how different metrics reveal different information in different places by graphing them\n",
"2. Graph and measure the clusteredness of neighbourhoods surpassing different threshholds of queerness\n",
"3. If the previous steps show that this is a relevant line of inquiry: measure and graph the rate of change in queerness radially outward from clusters of queer neighbourhoods\n"
]
2023-02-01 01:23:45 +00:00
}
],
"metadata": {
2023-02-16 00:29:26 +00:00
"kernelspec": {
2023-03-03 09:13:54 +00:00
"display_name": "Python 3",
2023-02-16 00:29:26 +00:00
"language": "python",
"name": "python3"
},
2023-02-01 01:23:45 +00:00
"language_info": {
2023-02-16 00:29:26 +00:00
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
2023-03-03 09:13:54 +00:00
"version": "3.11.1"
},
"vscode": {
"interpreter": {
"hash": "b2baa059f790e7ad780c83135aaea020c73a7a7a6921010b599b8b664933698d"
}
2023-02-01 01:23:45 +00:00
}
},
"nbformat": 4,
2023-02-16 00:29:26 +00:00
"nbformat_minor": 4
}