pride-data-analysis/analysis/analysis1.ipynb

1199 lines
9.5 MiB
Plaintext
Raw Normal View History

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",
"**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",
"**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
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Analysis Pipeline"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import seaborn as sns\n",
"import numpy as np\n",
"from PIL import Image\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib.patches as mpatches\n",
"from matplotlib.colors import LinearSegmentedColormap\n",
"\n",
"sns.set_theme(style=\"white\")\n",
"sns.set(font_scale=1.2)\n",
"sns.set_palette(\"copper_r\")\n",
"plt.rcParams[\"axes.labelsize\"] = 12\n",
"\n",
"# Absolutely diabolical method of doing relative imports with a package who shares its name with\n",
"# something in the stdlib in Jupyter Lab because it seems impossible otherwise\n",
"__import__(\"sys\").path.append(\"./code\")\n",
"from project_functions1 import *\n",
"\n",
"CITIES = [\n",
" { \"name\": \"Atlanta\", \"pos\": (-84.791944, -84.001944, 33.478333, 34.0375) },\n",
" { \"name\": \"Austin\", \"pos\": (-98.071667, -97.371111, 30.033889, 30.569722) },\n",
" { \"name\": \"Boston\", \"pos\": (-71.284444, -70.880278, 42.206389, 42.484444) },\n",
" { \"name\": \"Chicago\", \"pos\": (-88.044167, -87.508333, 41.624444, 42.026389) },\n",
" { \"name\": \"Denver\", \"pos\": (-105.104444, -104.625556, 39.578611, 39.920278) },\n",
" { \"name\": \"Houston\", \"pos\": (-95.858333, -95.013056, 29.472778, 30.134167) },\n",
" { \"name\": \"Los Angeles\", \"pos\": (-118.615556, -117.618333, 33.701111, 34.411667) },\n",
" { \"name\": \"Miami\", \"pos\": (-80.2375, -80.145833, 25.734722, 25.812222) },\n",
" { \"name\": \"New York\", \"pos\": (-74.459722, -73.393333, 40.355556, 41.102222) },\n",
" { \"name\": \"New Orleans\", \"pos\": (-90.220833, -89.915833, 29.813056, 30.045556) },\n",
" { \"name\": \"Philadelphia\", \"pos\": (-75.344167, -74.94, 39.846667, 40.146389) },\n",
" { \"name\": \"Portland\", \"pos\": (-122.795278, -122.493333, 45.465556, 45.654444) },\n",
" { \"name\": \"San Francisco\", \"pos\": (-122.521667, -122.352778, 37.690278, 37.812222) },\n",
" { \"name\": \"Seattle\", \"pos\": (-122.473056, -122.151667, 47.493333, 47.718611) },\n",
" { \"name\": \"Washington DC\", \"pos\": (-77.1125, -76.919722, 38.833333, 38.963889) },\n",
"]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data Analysis Pipeline"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"# Now in one, new-and-improved, non-descript method imported from another file\n",
"gb, pol, counties, cords = load_and_process()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"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>SS_Index</th>\n",
" <th>TOTINDEX</th>\n",
" <th>lat</th>\n",
" <th>long</th>\n",
" <th>kinsey</th>\n",
" <th>percent_democrat</th>\n",
" <th>neighbourhood_kinsey</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>55.012669</td>\n",
" <td>67.077054</td>\n",
" <td>34.093828</td>\n",
" <td>-118.381697</td>\n",
" <td>6</td>\n",
" <td>0.456450</td>\n",
" <td>1.132075</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>58.412517</td>\n",
" <td>61.866815</td>\n",
" <td>37.758057</td>\n",
" <td>-122.435410</td>\n",
" <td>6</td>\n",
" <td>0.742633</td>\n",
" <td>2.533333</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>30.731192</td>\n",
" <td>37.908747</td>\n",
" <td>40.742039</td>\n",
" <td>-74.000620</td>\n",
" <td>6</td>\n",
" <td>0.775215</td>\n",
" <td>1.091667</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>21.995808</td>\n",
" <td>37.530067</td>\n",
" <td>40.734012</td>\n",
" <td>-74.006746</td>\n",
" <td>6</td>\n",
" <td>0.794248</td>\n",
" <td>1.101695</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>21.284224</td>\n",
" <td>35.843573</td>\n",
" <td>37.773134</td>\n",
" <td>-122.411167</td>\n",
" <td>5</td>\n",
" <td>0.742633</td>\n",
" <td>2.533333</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2323</th>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>45.528666</td>\n",
" <td>-122.678981</td>\n",
" <td>0</td>\n",
" <td>0.753689</td>\n",
" <td>1.708333</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2324</th>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>47.606211</td>\n",
" <td>-122.333792</td>\n",
" <td>0</td>\n",
" <td>0.545340</td>\n",
" <td>2.148148</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2325</th>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>47.449678</td>\n",
" <td>-122.307657</td>\n",
" <td>0</td>\n",
" <td>0.543670</td>\n",
" <td>1.357143</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2326</th>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>47.604569</td>\n",
" <td>-122.335359</td>\n",
" <td>0</td>\n",
" <td>0.545340</td>\n",
" <td>2.148148</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2327</th>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>47.649339</td>\n",
" <td>-122.310294</td>\n",
" <td>0</td>\n",
" <td>0.545340</td>\n",
" <td>1.714286</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>2328 rows × 7 columns</p>\n",
"</div>"
],
"text/plain": [
" SS_Index TOTINDEX lat long kinsey percent_democrat \\\n",
"0 55.012669 67.077054 34.093828 -118.381697 6 0.456450 \n",
"1 58.412517 61.866815 37.758057 -122.435410 6 0.742633 \n",
"2 30.731192 37.908747 40.742039 -74.000620 6 0.775215 \n",
"3 21.995808 37.530067 40.734012 -74.006746 6 0.794248 \n",
"4 21.284224 35.843573 37.773134 -122.411167 5 0.742633 \n",
"... ... ... ... ... ... ... \n",
"2323 0.000000 0.000000 45.528666 -122.678981 0 0.753689 \n",
"2324 0.000000 0.000000 47.606211 -122.333792 0 0.545340 \n",
"2325 0.000000 0.000000 47.449678 -122.307657 0 0.543670 \n",
"2326 0.000000 0.000000 47.604569 -122.335359 0 0.545340 \n",
"2327 0.000000 0.000000 47.649339 -122.310294 0 0.545340 \n",
"\n",
" neighbourhood_kinsey \n",
"0 1.132075 \n",
"1 2.533333 \n",
"2 1.091667 \n",
"3 1.101695 \n",
"4 2.533333 \n",
"... ... \n",
"2323 1.708333 \n",
"2324 2.148148 \n",
"2325 1.357143 \n",
"2326 2.148148 \n",
"2327 1.714286 \n",
"\n",
"[2328 rows x 7 columns]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"gb.to_csv(\"../data/processed/gaybourhoods-nat.csv\")\n",
"\n",
"SS_INDEX_MAX = gb.SS_Index.max()\n",
"\n",
"gb"
]
},
{
"cell_type": "code",
"execution_count": 4,
"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>county</th>\n",
" <th>lat</th>\n",
" <th>long</th>\n",
" <th>percent</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Autauga AL</td>\n",
" <td>32.532237</td>\n",
" <td>-86.646439</td>\n",
" <td>0.265878</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Baldwin AL</td>\n",
" <td>30.659218</td>\n",
" <td>-87.746067</td>\n",
" <td>0.215894</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Barbour AL</td>\n",
" <td>31.870253</td>\n",
" <td>-85.405103</td>\n",
" <td>0.513685</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Bibb AL</td>\n",
" <td>33.015893</td>\n",
" <td>-87.127148</td>\n",
" <td>0.261520</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Blount AL</td>\n",
" <td>33.977357</td>\n",
" <td>-86.566440</td>\n",
" <td>0.123719</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2879</th>\n",
" <td>Sweetwater WY</td>\n",
" <td>41.660328</td>\n",
" <td>-108.875677</td>\n",
" <td>0.282569</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2880</th>\n",
" <td>Teton WY</td>\n",
" <td>44.048662</td>\n",
" <td>-110.426087</td>\n",
" <td>0.541957</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2881</th>\n",
" <td>Uinta WY</td>\n",
" <td>41.284726</td>\n",
" <td>-110.558947</td>\n",
" <td>0.190655</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2882</th>\n",
" <td>Washakie WY</td>\n",
" <td>43.878830</td>\n",
" <td>-107.669052</td>\n",
" <td>0.201318</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2883</th>\n",
" <td>Weston WY</td>\n",
" <td>43.846213</td>\n",
" <td>-104.570020</td>\n",
" <td>0.125633</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>2884 rows × 4 columns</p>\n",
"</div>"
],
"text/plain": [
" county lat long percent\n",
"0 Autauga AL 32.532237 -86.646439 0.265878\n",
"1 Baldwin AL 30.659218 -87.746067 0.215894\n",
"2 Barbour AL 31.870253 -85.405103 0.513685\n",
"3 Bibb AL 33.015893 -87.127148 0.261520\n",
"4 Blount AL 33.977357 -86.566440 0.123719\n",
"... ... ... ... ...\n",
"2879 Sweetwater WY 41.660328 -108.875677 0.282569\n",
"2880 Teton WY 44.048662 -110.426087 0.541957\n",
"2881 Uinta WY 41.284726 -110.558947 0.190655\n",
"2882 Washakie WY 43.878830 -107.669052 0.201318\n",
"2883 Weston WY 43.846213 -104.570020 0.125633\n",
"\n",
"[2884 rows x 4 columns]"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pol.to_csv(\"../data/processed/election-2012.csv\")\n",
"pol"
]
},
{
"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": 6,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkMAAAHT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YuvPqlWrePbZZ/F6vVVQShGpSApDFSA2NpabbrqJJ598kpdeeom///3vJ/W46dOns3DhQtauXcuePXtwOBx4PB6uvvpqhg0bVmz7o5sUZ8+ezX333ccNN9zAww8/XGx7n8/H+eefT0xMDIsWLYq4RDdr1iwmT57MunXrKCwspEmTJgwdOpTRo0fjcrlOWPZ9+/axdetWateuXWIQAkhPTy9x+a5du3jjjTf48ssv2bVrF7GxsTRt2pQ+ffowZsyY8Hbfffcds2fPZvny5ezatYtAIEDTpk256KKLuOWWWyIuSRZdigS4/vrrI/a3fv36iD4Y/fr1C/+/cePGEZdycnJyePPNN5k3bx47duzA6XTSpk0bbrnlFi644IKI550+fToPPfQQTz75JMnJybzyyitkZGTgdDo577zzuO+++2jevPkJavKwTz75hHfffZeMjAz8fj/NmjVjyJAh3HjjjeG/yZIlSyKO78jjOtkm8927d/Pyyy/zxRdfsHv3bmrVqkWXLl24/fbbadOmTXi7otcbwNKlS8P76tatG++8806Jz13a8mVlZTF27FgWLlxITk4OzZo146abbuKKK64o8fm/+uorJkyYwA8//EBeXh4NGjRgwIAB3HHHHSQkJJzw2AHefvttNmzYQJcuXRg7diw2W8ldKTt06MCECRMIhUIRy+fNm8ecOXNYs2YNmZmZAJx11llcdtllXHfddRHPd9999zF79mzeeecdunXrVmwfn332GX/4wx+49tpr+cc//hGxzufz8dJLL/Hxxx+ze/duGjRowGWXXcatt95a4nv022+/5Y033mDNmjXk5+fTuHFjBgwYwG233Ubt2rUjtj3eZcxjXW5OS0ujW7duPPfcc/znP//hyy+/ZO/evTz++ONcfvnl4e1K8zcNhUJMnjyZDz74gE2bNmGaJi1atOCKK67gd7/7XYl/m9IcJ8CPP/7I2LFjWbFiBYZh0K5dO+65555i2xX5/vvveeONN1i7di1ZWVkkJibSuHFjevXqxV133XXMxx3J5/Px+uuvM2PGDHbt2kVKSgpDhw6NOL8dKTMzk6lTp7J48WK2bdvG/v37SUpK4txzz+WOO+6gZcuW4W2L/j4AM2bMYMaMGeF1Tz75JJdffjk+n48pU6bwxRdf8PPPP7Nnzx7i4uI455xzuPHGG7nwwgtP6jjA6jM4fvx4Pv30U3bu3IlpmtStW5c2bdowevToiHMGwOrVq3nzzTdZvnw5+/fvp27dulx44YWMGTOG1NRU4PBlviJHnieOd34pTwpDFeTaa6/l3XffZfLkyYwaNeqkPgQfffRRWrZsSdeuXalfvz45OTl88cUX/PnPf2bz5s3ce++9x318//79qV27NrNmzeLPf/5zsf5I8+bNIzc3l5tuuili3UMPPcT06dNp0KABAwcOJCEhgVWrVvH888/z7bff8vbbb5+wb1Pt2rVxOBzk5+eze/duUlJSTni8AGvWrGH06NHk5OTQtWtXBgwYgNfr5eeff+bFF1+MOFm8/vrrbN68mY4dO3LhhRfi8/lYsWIFL7zwAkuWLGHcuHHY7XbACkDz589n6dKlDB8+nMaNG0fs96677mLevHlkZGRw/fXXhz84jzx57tixg1GjRrFjxw66dOlCz549KSgoYOHChYwePZp//vOfjBgxotgxzZ07l6+++or+/fvTrVs31q1bx2effcaSJUuYNGkSZ5111gnr5bnnnuPVV1+lTp06DBkyhLi4OL766iuee+45Fi9ezJtvvonL5aJx48bcddddjB8/HoAbbrgh/Bxnn332Cfezbds2rrnmGnbv3k337t0ZPHgwv/32G3PmzGHRokW88MIL9OnTB7DCS7du3XjxxRdp3LhxOPQeXbdHKk35cnNzufrqq3G5XAwaNAifz8ecOXN4+OGHsdlsxUL2iy++yAsvvEBSUhK9e/cmOTmZDRs28NZbb/Hll18yefJkatWqdcI6+OCDDwC48847jxmEihiGEX6NFXnmmWew2Wy0a9eO1NRUDhw4wHfffcfjjz/OmjVr+Pe//x3e9uqrr2b27NlMnjy5xDA0efJkAH73u98VW3fPPfewZs0aLrroIhwOB/Pnz+eFF17gxx9/5OWXX8YwjPC277//Po8++ihut5uLLrqIunXrsnTpUl5//XUWLlzIpEmTTjosHk9OTg4jR44kLi6OgQMHYhgGdevWDa8v7d/0T3/6E7NmzaJhw4ZceeWVGIbBvHnzeOyxx1i+fDnPPvtsxPalPc4VK1Zw44034vf7GTBgAM2aNWPdunWMGjWK7t27Fzu+L7/8kttuu41atWrRt29fUlNTycnJYdOmTbz33nsnFYZM0+Tee+9l/vz5NG3alOuuuw6/38+0adPYsGFDiY/5/vvvef311zn33HMZOHAgcXFxbN26lc8++4wFCxYwadKk8JfLbt26cf311zNhwgTS09Pp379/+HmK3mP79+/n8ccfp2PHjvTo0YPk5GT27NnDwoULufXWW/nXv/7FVVdddVLHMnr0aFauXEnHjh256qqrsNvtZGZmsmTJErp06RIRhj744AP+8Y9/4HK56Nu3Lw0aNGDr1q1MnTqVBQsWMGXKFBo1akRCQgJ33XUXM2bMYMeOHRH1erzzS7kypVx5PB6zZ8+epmma5qeffmp6PB5zzJgxEdv06dPH9Hg8pt/vj1i+devWYs9XWFhoXn/99eY555xj7tq1K2LdddddZ3o8nohlf//7302Px2MuWLCg2HPdcsstpsfjMTMyMsLLpk2bFi5jQUFBxPb//e9/TY/HY44bN+4kjtw07777btPj8Zj9+vUz33jjDXPVqlVmfn7+MbcvLCwM18VHH31UbP1vv/0W8fuvv/5qhkKhYtuNHTvW9Hg85uzZs0ss/3fffVfi/v/yl7+YHo/H3LZtW4n
"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",
")\n",
"\n",
"plot_naive_scatter1.figure.savefig(\"./images/graphs/1-naive-scatter1.png\")"
]
},
{
"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": 7,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEU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G4De/+Q3Ky8t11zl27BgefPBBXHrppeF30uTJk/Gb3/xG9SxZfRc3b96M2bNnIz8/H0OGDMHtt9+Or7/+2vL+mtJG+fc4EAjg2WefRWFhYfiYv/3tb6r3hNxOAKrfbqV21UwTe+jQIfz973/H9OnTMWzYMPTt2xdjx47Fgw8+iBMnTljez/nAhg0b8NOf/hRDhw5F3759MWHCBPz1r39FbW2t4f7R+Ees71izd+Hp06fxj3/8A5dddhlyc3MxePBg/OQnP8HmzZt1+yr1xPv378f8+fMxaNAg5OXl4YYbbsD27dub3B/NlhNcf/31+O9//4slS5Zgzpw5MS2j/O53v0NWVhYGDx6MDh06oKamBp9++inuu+8+HDp0CHfffbfl8RMmTECbNm2watUq3HfffTq97UcffYTa2lrcfPPNqm0PPPAAli9fjo4dO6KwsBBt27bFzp078dhjj+Gzzz7DokWLomp327RpA7vdjvr6elRUVMQcmdm9ezduueUW1NTUYPDgwbj00kvh9Xrx1Vdf4cknnwz/AALAv/71Lxw6dAj9+/fHmDFj4PP5sH37djzxxBPYunUrFi9eHNZ23Xjjjfj444/x+eefY9q0aejUqZPqugsXLgwvBd94441o27Zt+D5klJWVYc6cOSgrK8OgQYMwatQoNDQ0YO3atbjlllvwhz/8IfyDqsSaNWuwYcMGTJgwAUOGDMH+/fvxwQcfYOvWrXj
"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",
")\n",
"\n",
"plot_naive_scatter2.figure.savefig(\"./images/graphs/2-naive-scatter2.png\")"
]
},
{
"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": 8,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAArEAAAHTCAYAAAAwDkDhAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOxdd3xV5f1+zjl3JiETEpBhZNwEyGIoCAhhGBdgWaIoitSCWrRSq9a2dv3a2tqqdVXpEBxVQUBFcOAAERSskIShAZQNkkgGIePu9/fHe8+9Z7xn3Juwz/P5+JHcs97znvW83/f5Pl+OEEJgwYIFCxYsWLBgwcJZBP50N8CCBQsWLFiwYMGChXhhkVgLFixYsGDBggULZx0sEmvBggULFixYsGDhrINFYi1YsGDBggULFiycdbBIrAULFixYsGDBgoWzDhaJtWDBggULFixYsHDWwSKxFixYsGDBggULFs46WCTWggULFixYsGDBwlkHi8RasGDBggULFixYOOtwRpPYmTNnIi8v73Q3w0Ib8POf/xx5eXk4dOjQ6W6KaTQ1NeEPf/gDxowZg379+iEvLw9ff/316W7WWY3ly5cjLy8Py5cvl/0+ZswYjBkzxtS6pwvbtm3DrbfeiiFDhiAvLw/XXnvt6W7SScXZ+MxaODlI5Fk8U++fQ4cOIS8vDz//+c/btJ9NmzYhLy8PTz31VDu1TI0zkfvk5eVh5syZp7sZKtji3UDs2AsuuADvvfcenE6nap0xY8bg8OHD2LFjB2y2uA9xRmPPnj14/vnnsWnTJhw9ehSCICAzMxO5ubkYOHAgrr/+enTs2PGUtOWpp57C008/jRdffBFDhgxRLf/5z3+ON954Ax999BG6det2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++GLcd999qK+vN9W3Zu8lEa+99homTJiAwsJCDBs2DA899BBOnDjBXDeea6OFSy+9FGPGjFFJBjp16oTrr78eAFSSl/feew91dXW45pprogQWoNPzP/nJTwAAr776qmybtLQ0XHrppUhPTzfVLrvdjjvuuEMVpOB5Hj/+8Y8B0HdVW2G326PvE2m/ie+h77//Hr/85S9x2WWXoW/fvrJnpLKyEnfffTeGDx+OgoICjBo1Cr/+9a9RXV2tOs7Bgwfx0EMP4fLLL49+kyZMmIBf//rXsntJ71n87LPPMGPGDJSUlOCSSy7BnXfeiW+//Vb3/OJpo/g+DgaDeO6551BWVhbd5q9//avsOyG2E4Ds3S3VrmppYvfu3Yu//e1vmDx5MoYOHYqCggKMHj0aDz30EI4ePap7PqcDn376KX70ox9hyJAhKCgowLhx4/CXv/wFjY2NzPWN+IfZb6zWt/DEiRN49NFHccUVV6CwsBAXX3wxfvjDH+Kzzz5TrSvVE3/99deYM2cOBg8ejOLiYtx0003YsmVL3P2RsJzgxhtvxH//+18sXrwYM2fONDWN8tvf/ha9e/fGxRdfjE6dOqGhoQGffPIJ7r//fuzduxf33HOP7vbjxo1Dhw4dsHLlStx///0qve2HH36IxsZGzJ49W7bswQcfxPLly9G5c2eUlZUhNTUVFRUVeOKJJ/D5559j4cKFhtrdDh06wGazoaWlBTU1NaYjM9u2bcNtt92GhoYGXHzxxbj88svh9XrxzTff4Omnn46+AAHgX//6F/bu3YsBAwZg1KhR8Pv92LJlC5566ils2rQJixYtimq7br75Znz00Uf44osvMGnSJHTt2lV23Hnz5kWngm+++WakpqZGz0PE4cOHMXPmTBw+fBiDBw/GZZddhtbWVqxZswa33XYbfv/730dfqFKsXr0an376KcaNG4dLLrkEX3/9Nd5//31s2rQ
"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",
")\n",
"\n",
"plot_naive_scatter3.figure.savefig(\"./images/graphs/3-naive-scatter3.png\")"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlcAAAJKCAYAAAABc2DBAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydeZwcVbn+n1PVe/fsM9mGhADJJGEXiCAiyL4omwpuRAUVF3ABvCIXrteruFzcEQU3lh9wBZSwJiiyKDsJZAFCNkLWmWQy+0zv3VXv749TVdNLdXdVT2eZyfv9fDRDd71d55yqOuepU6feRxARgWEYhmEYhqkJyp4uAMMwDMMwzESCxRXDMAzDMEwNYXHFMAzDMAxTQ1hcMQzDMAzD1BAWVwzDMAzDMDWExRXDMAzDMEwNYXHFMAzDMAxTQ1hcMQzDMAzD1BAWVwzDMAzDMDWExdUE4ZRTTsGcOXPw6quv7umiVM2cOXMwZ84cbNu2bU8XhWFc8Z3vfAdz5szBb37zmz1dlHHBggULMGfOHCxcuHBPF8U1e3PZt23bZvWjzJ7FM5bgRCKBhx56CM899xzWrFmDgYEBCCHQ3NyMQw89FKeeeirOPPNMBAKBWpV3j2F2mp/97GdRX1+/h0uzb7F69Wo89dRTaG9vx0c+8pE9XRxmH2J4eBh33XUXAOBrX/vaHi7N7mNv7e++853v4KGHHsJ73/te3H333TXbthZMhHNlcHAQf/nLX/Dvf/8b7777LmKxGBoaGtDa2opZs2Zh/vz5OOGEEzB9+vS8uKeeegqrV6/Ge9/7Xhx77LE1L9d4HAOqFlfPPPMMvvvd76Knp8f6LBQKQQiBzs5OdHZ24h//+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iKZTCIajcLr9aKhoSHve6/Xi6OOOgozZ87Epk2b8Pjjj2PBggW2v/Xggw+CiHDUUUc5FlaAfOSzatUqALJjCYVCGBoawsqVK7Fy5UosWrQId911l21H3N3djS996UtYvXo1AHns6uvr0dPTg66uLrz44ouYOXOm7TqFxYsX4z/+4z+QzWZRV1dX1OnktrEQAnV1dejr68NTTz2Fp556CpdffnnRo6qRkRF84hOfwDvvvGOVx4zr6enBqlWroKoqvvWtb1kx999/P7773e9a/x0MBqHrOjZv3ozNmzfj6aefxoUXXpjX6VaimnapRb/x29/+FjfffDMURUE4HEY8HsfKlStxzTXXoLe3F5/73OesbRsaGtDU1ISBgQEA8lzMpdTgV4oXXngBV1xxBZLJJOrq6pDNZrFx40bcfPPNWLVqVdE6FpOf/vSn+NOf/mT9dyQSwdDQEF5++WW8/PLLeOaZZ/Czn/2spLitdX9n8uKLL+Kb3/wmAHn+1dfXQwiBrq4udHV14e9//zt++MMf4oILLnDVTruTNWvW4Prrr8fg4CDC4TCICJ2dnbj99tuxZMkS3HfffUVrQO1we648+eST+Na3vmXNAgWDQWQyGaxatQqrVq3CY489hjvuuKPod2KxGC699FKsXLkSgOz/EokEFi9ejH/961/4wQ9+UHVbAPLxHxE5fvTn9XrR2tqKkZERpFIphEKhstfFZZddhsHBQQCyzsFgEIODg1iyZAmWLFmCf/7zn/jd734Hj2dUmjgZA3Kp5npZtWoVFixYgFgsZv1mMBi0zuUlS5Zg3rx5OPHEEx21CwCAXPDII49QR0cHdXR00DvvvOMmNI/Pf/7z1NHRQfPnz6fFixdTNpslIqI33niDPvzhD1NHRwcdf/zx1NfXlxd38803U0dHB1177bUlf/vaa6+ljo4Ouvnmm/M+f+WVV6ijo4OOOOIIOuS
"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\")\n",
"\n",
"_ = plot_naive_hexbin.figure.suptitle(\"County density across continental United States\")\n",
"_ = plot_naive_hexbin.ax_joint.set(xlabel=\"Longitude\", ylabel=\"Latitude\")\n",
"plot_naive_hexbin.figure.subplots_adjust(top=.925)\n",
"\n",
"plot_naive_hexbin.figure.savefig(\"./images/graphs/4-plot-naive-hexbin.png\")"
]
},
{
"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": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2023-03-26 00:17:34 +00:00
"Number of data points in the region of Boston: 131\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlEAAAHBCAYAAABJ8u4AAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAACwoElEQVR4nOzdeZxcVZn4/8+5W+3Va7rT6ez7RghhVxAxEBE3RgGRr1FAQAVGxtEZdQTFkR8qw4iMzow4KogzKCiDG4qOICgqsmUhCSQhZO8t6a32utv5/VFJJ52u6vTe1Z3zfr14Affcqjp1q7rqqbM8j5BSShRFURRFUZRB0ca7A4qiKIqiKBORCqIURVEURVGGQAVRiqIoiqIoQ6CCKEVRFEVRlCFQQZSiKIqiKMoQqCBKURRFURRlCFQQpSiKoiiKMgQqiFIURVEURRkCFUQpiqIoiqIMgQqiFEVRFEVRhsAY7w4cj+/7XHHFFWzYsIGzzz6b+++/v6ftySef5IknnmD9+vU0NTURCASYNWsWl112GZdccgmGMfCn5/s+P/7xj3nkkUfYvn07AA0NDbzlLW/hU5/61Eg/LUVRFEVRJriyD6K+//3v9wQ1x7r11lsJhUJccMEFzJs3j2QyyWOPPcbnPvc5fvvb33LvvfcihDjuY7iuy9/+7d/yhz/8gbe97W38zd/8DUII9u/fz/79+0f6KSmKoiiKMgmUdRC1d+9e7rnnHj7xiU9wxx139Gm/6667OOuss3oFSh/60IdYu3YtTz/9NH/4wx8477zzjvs49957L0899RTf/va3Offcc0f0OSiKoiiKMjmV9ZqoW265hfnz57N27dqi7WeffXafkSZd17nooosA2Lp163EfI5vNct9993H++edz7rnnIqUklUohpRz+E1AURVEUZdIq25Gohx9+mBdeeIFHHnkETRtcrNfa2gpATU3Ncc998cUXSSaTrFixgq9+9av8+Mc/JplMEolEeOtb38o//uM/UlVVNaTnACClxPf7D8g0TRz3nBOZuj79U9fn+NQ16p+6PsenrlH/Jtv10TQxoOVAZRlEtba2cuedd3L11VezePHiQd22paWFhx56iIqKClavXn3c83fs2AEU1l7pus7NN99MXV0dv/vd7/jf//1fNm3axE9+8hMCgcCQnguArh8/CNT1479YJzJ1ffqnrs/xqWvUP3V9jk9do/6diNenLIOo2267jaqqKm666aZB3S6dTnPDDTeQSqX4xje+QWVl5YBuA9Dd3c3Pf/5z5s+fD8Bb3/pWAH7+85/z05/+lPe9732DexKH+L4kkciUbNd1jXg8RCKRxfP8IT3GZKauT//U9Tk+dY36p67P8alr1L/JeH3i8dCABkDKLoh67LHHePLJJ7nvvvsIBoMDvl06neb6669ny5Yt3HrrrVx44YUDut3hx1ixYkVPAHXYe9/7Xn7+85/z7LPPDjmIAnDd47+pPM8f0HknKnV9+qeuz/Gpa9Q/dX2OT12j/p2I16esgijbtrn99ts555xzaGxsZPfu3b3ac7kcu3fvJhKJUFtb23M8lUpx3XXXsW7dOm677TauuOKKAT/m1KlTAairq+vTNmXKFKAwSqUoiqIoinK0sgqicrkcHR0dPPPMM6xZs6ZP+7p161izZg0XX3wxd999NwDJZJJrr72WjRs3cvvtt3PppZcO6jFPPvlkAJqbm/u0tbS0AANboK4oiqIoyomlrIKoUCjEPffcU7Tt5ptvZuHChdx44400NDQAhQDqmmuuYfPmzXz5y1/m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7ruOGsZWlCFoby9Ma9XV1R/33Lq6qQAcPHhgVPsEoGkaN9xwM5/85N/
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
2023-03-26 00:17:34 +00:00
"# Boston 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",
2023-03-26 00:17:34 +00:00
"print(f\"Number of data points in the region of Boston: {gb_ny.shape[0]}\")\n",
"plot_boston_scatter1 = sns.scatterplot(data=gb_ny, x=\"long\", y=\"lat\", hue=\"TOTINDEX\")\n",
"_ = plot_ny_scatter1.set(\n",
" xlabel=\"Longitude\",\n",
" ylabel=\"Latitude\",\n",
2023-03-26 00:17:34 +00:00
" title=\"Queer Neighbourhoods in Boston\"\n",
")\n",
"\n",
"plot_boston_scatter1.figure.savefig(\"./images/graphs/5-plot-boston-scatter1.png\")"
]
},
{
"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 \"SS_Index\" column:"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
2023-03-26 00:17:34 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlEAAAHTCAYAAAAH7E2QAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAADRnklEQVR4nOzdd5hU1f348fctU7cXdmGXXhaQDoqCIFIUazRRozESu8aWxJ+aaIyJydcSSzR2McbejV0UC6iIjQ7Se11gF7ZNn7n3nt8fwy6MO7O9zC7n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3I4T+oQSktLAejatWu953br1g2gzqGh+pSXl/P+++8zdOhQLr/88pgyh8PBTTfdhBCCDz74oOb4iy++CMD//d//1erl+MUvfsHgwYNjzj/UzTffjNvtbnJ9TzrpJEaNGsVnn33GokWL6jz31VdfJRKJcOutt5Kfnx9TNm7cOKZMmcIXX3yB1+ut83neffddAP7whz/E9Bylp6dz9dVX1/nYeMOD55xzDhBdfRnPVVddRUZGRs2/HQ5Hza/1Q4fH3n//fSKRCBdccEGtuTjXX389KSkpvPfeey0yXGSz2fjTn/6UcNWXy+XilltuQdO0mmP9+/dn9OjRbNq0CZ/PV3O8+h5uuOEGUlJSao673W5uuukmAN58880m3+eSJUvYsmULRx11VE1vSbULLriAnj17JrzPeCs/W2r+3Y033khmZmbNv91uN6effjqWZbFy5cpGPdeCBQt49NFHefTRR3n
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plot_boston_scatter2 = sns.scatterplot(data=gb_ny, x=\"long\", y=\"lat\", hue=\"SS_Index\")\n",
"_ = plot_boston_scatter2.set(\n",
" xlabel=\"Longitude\",\n",
" ylabel=\"Latitude\",\n",
2023-03-26 00:17:34 +00:00
" title=\"Queer Neighbourhoods in Boston\"\n",
")\n",
"\n",
"plot_boston_scatter2.figure.savefig(\"./images/graphs/6-plot-boston-scatter2.png\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"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": 14,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAApgAAAHTCAYAAACDRmj7AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywga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S8vj507d/L+++9zxx13MGbMmIBZF8DhcPDCCy9w6623MmbMGMaMGcOCBQv48Y9/TFNTU9D+HA4Hf/rTn7j55psZPXo0Y8aM4a677mLVqlUhx965cyd5eXk8++yzHD9+nEcffZSxY8dSVFTEvffey759+4K2nzVrFr///e8BuP/++8nLywv883P27Fn+93//l1tvvZWJEydSWFjIzJkz+f73v09dXV3YfnS73Tz77LOB/po1axa/+c1vcLvdffoOer1e/va3v3HnnXdSXFxMUVERt9xyC6+99hqqqoY9Tl+Ul5fzrW99i2nTplFYWMjUqVP51re+RXl5ecj5z5w5E4AVK1YEzr0/n6f6+nqGDx/OLbfc0uc2jzzyCHl5eZw8eTJo+Zo1a/jSl75ESUkJo0aNYtGiRfzpT3/C7XYHtvFfw+rqaqqrq4OuSc92hevHnvfehx9+yO23305RURHjx4/nqaeeor6+Pmx7Dx06xMMPP8yYMWMoLi7mwQcfZP/+/UH7uxT8vkWVlZW8+OKLXH/99YwcOZLp06fz05/+lK6urrC/O3LkCF/72teYNGlS4P767//+bxoaGq7KMfrzVx2IP9RAnoWnn36a+++/H4Df//73QdfR35/9+WBeTp9UVVXxxhtvsGjRIkaOHMnkyZP5/ve/T2dn50XPDeCNN94gLy+PZcuWBS1fvnw5eXl5FBUVBd2rAHfccQcjR47E6XSG7K+qqoqnnnqKCRMmMHLkSG699VY2bNgQ9thut5sXXniBRYsWUVRURHFxMUuWLGHNmjWX1HaA66+/nsLCQlpaWsKuf+GFF8jLy+O1114LWn6pfZ2Xl8eKFSsAmD17duB69ny3A7S1tfHMM8+wYMECRo0aRUlJCQ888ABbtmwJ266uri5+9rOfMX36dEaOHMn111/Piy++iKZpl3zul0JmZiYvvPACgwcP5vjx47z++ush21zuWLdq1SpuvfVWioqKmDp1Kj/72c8C98r27du57777KC4uZty4cXzzm9+ktbU1bBsHct/DpY+lPd8br776KosWLWLUqFGB94Lb7ea1117jK1/5CjNnzqSwsJDx48fz4IMP8umnnwYd81Lf0RdD07SLvsMURWHGjBkUF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OPvroI5566ilKS0v593//94u2f/Hixfz6179m9erVYT8o3n33XQwGAwsXLgwsG0hfP/HEE3z88ceUlpZy//33ExUVBRBkha6urua+++6jurqasWPHMm3aNBwOBxs2bOCRRx7hhz/8YVDfut1uHnzwQQ4fPkx+fj6LFi2is7OTP/zhD+zateui5zxQLBYLDz/8MP/5n//J+++/z4MPPhhYd7lj3WuvvcamTZuYM2cO48ePZ+vWrbz00ku0t7cze/ZsnnrqKa677jruuusu9u/fz8qVK2ltbeXPf/5z0H4Get8PZCz185Of/IQ9e/YwY8YMZsyYgSRJgX395Cc/YcyYMUyePJm4uDgaGxvZsGEDjz76KD/+8Y+54447AK7KOxou7R0mSRJ33HEHzz77LKtXrw66d8D3TK5cuZLExMQQ/9twDKTPKisrWbJkCQ0NDUycOJEbb7yR2tpaPvzwQzZu3Mizzz4bMNBcKZfy7rpYv0dHR3PDDTfwzjvvsG3bNqZMmRJ0jNraWjZt2kRBQQEjR4689MZpAyQ3N1fLzc0NWb5161YtLy9Py8vL06qqqjSPx6PNmTNHKyws1Hbu3Bm0bV1dnTZ16lRtypQpmsvlCiz/3e9+p+Xm5mpFRUXa0aN
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plot_democrat_scatter = sns.scatterplot(\n",
" data=pol,\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",
")\n",
"\n",
"plot_democrat_scatter.figure.savefig(\"./images/graphs/7-plot-democrat-scatter.png\")"
]
},
{
"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",
" 3. 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"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Analysis"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2023-03-26 00:10:24 +00:00
"## Visualiztion strategy\n",
"Seaborn doesn't provide an easy interface for plotting data over maps. To do this, we will take a best-effort approach to rendering maps over an interval of coordinates and overlaying relevant plots on top of them using Matplotlib. The accuracy of these renderings will be limited by my access and knowledge of GIS tools, however, the goal is to represent the data spatially and the physical maps are entirely ornamental.\n",
"\n",
"To create a render for a city:\n",
"1. Draw a square over the region in Google Earth\n",
"2. Note the coordinates of the corners of the square\n",
"3. Screen shot the map over the marked region\n",
"4. Render the graph over the interval of coordinates\n",
"5. Render the image beneath the data\n",
"6. Adjust the position of the image to minimize obvious inaccuracies (for example, if a neighbourhood is plotted in a body of water)\n",
"\n",
"For example:"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkwAAAJKCAYAAADePRreAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOy9d7xuRXU+/szs8tbTbgGkqCieqwFEY0GQSCyABaNGbF/FYDQkij9r1BiNJhFr7KiJGrsmorGDJSo2YgNFMQRQQVQQbjn97XvPzO+PmTV77X3ec88FLucCdx4+l3PO++4ye/bMmmeetWaNMMYYBAQEBAQEBAQErAm5rwsQEBAQEBAQEHBrRyBMAQEBAQEBAQHrIBCmgICAgICAgIB1EAhTQEBAQEBAQMA6CIQpICAgICAgIGAdBMIUEBAQEBAQELAOAmEKCAgICAgICFgHgTAFBAQEBAQEBKyDQJgCAgICAgICAtZBIEwBNxsPechDsG3bNvzoRz/a10W53eP2VNd/93d/h23btuGcc87Z10W51eOcc87Btm3b8Hd/93f7uigl3FrLFRBwSyDe1wUI2PdYXFzEueeei+985zv47W9/i6WlJUxOTuJOd7oTTjzxRDzpSU/CzMzMvi7m7RqXX345vvGNb+CQQw7Bn//5n+/r4tyq8aMf/QhPf/rTS58JIdBsNtFut3HooYfiyCOPxIknnogHPvCBEELso5JuDD784Q9jZWUFj3vc43DooYfu6+JsCLZt2+Z/f8UrXrGqPRDyPMeRRx4JAPjoRz+KY489Ftdccw0e85jHYDAY4O///u/xF3/xF7u91+te9zp85CMfwZYtW3DeeeeVbGG/38fnPvc5fPe738UVV1yBhYUFCCGwadMmHHXUUXjoQx+KU045BfV6fS88dcC+RlCY9nN86UtfwkknnYS3vvWt+MlPfoL5+Xk0m00sLCzgpz/9Kd72trfh5JNPxpe+9KV9XdTbNS6//HK8613vwuc+97ndHnfYYYfh8MMPR6PR2KCS3boxMzODLVu2YPPmzZBSYseOHfjJT36Cj370o3jmM5+Jk08+GT/4wQ/2dTFvNmZmZnD44Ydj69atq7776Ec/ine961247rrrblXl2ii8733vQ7/f3+Pj73znO+N5z3seAODtb387fv/736957M9+9jN87GMfAwC86lW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mGOOwf3vf3/89V//NX7xi1+MPVcphe985zt41atehT//8z/H8ccfj6OOOgonnHACzjrrrH3qiti8eTPOOeccTExMIMsyvPvd717z2IsvvhgvfOEL8aAHPci/szPOOAPnnXcejDGrjv/Rj36Ebdu24SEPeQgA4Cc/+Qn++q//Gsceeyzuec974s/+7M/w8Y9/fOy5ADA3N4c3vvGNOPXUU3Gve90LRx99NE488UQ8+clPxjve8Y5V7rVxwdX0GR379Kc/vdRuqJ3T5+u16Ze97GXYtm0bXvziF+/2uPXKRaByXHvttfjDH/6AV77ylb5+yS7cGJIzDk960pNwhzvcAYuLi/jgBz94o8494ogj8JznPAcA8KY3vQnbt2/3311xxRX493//dwA2Rmrz5s3+u7e//e0YjUY48MAD8Za3vGXd+KRHPvKReMYznnGjyhZw60QgTPshbrjhBnz3u98FYCX1dru92+MnJia87P7tb38bN9xww9jjfve73+Hxj388/uu//gvLy8sQQuC6667DBz/4QTz+8Y/Hjh07Vp3ztre9DWeddRa++93vYm5uDrVaDYPBANdccw3OP/98vPa1r111TpZl+Nu//Vs8+9nPxgUXXIBdu3ahVqthfn4e3/rWt/CsZz0L//Iv/7LbZzr77LPxkpe8BD/5yU9gjIGUtiuceuqpAIAvf/nL0FqPPTfLMnzta18rHU/4y7/8S7z//e/HT3/6UywuLqLRaGBxcRE//vGP8cpXvhLPfvazked56ZwtW7b4d5AkCbZs2VL6txaZreLSSy/Fox71KHzoQx/Cb37zG0RRhCzL8Itf/AJvfOMb8YQnPAFzc3Nrnp/nOc4880y8/vWvx9VXXw0pJZaWlvDtb38bT33qU3HJJZesOueqq67CmWeeiXPPPReXXXYZhsMhkiTBzp078Y1vfANnnHEG3vve9+5R+W8JHHjggT6I/oILLkCv11t1zL/8y7/gqU99Kr785S9j+/btqNVqWFpawg9+8AO8+MUvxotf/OI12wJgifjpp5+O73znO1BKYTgc4sorr8RrXvMavO51r1t1/HXXXYfHPOYx+OAHP4hf/epXGI1GaDQa2L59Oy655BK85z3v8f1zd2g2m9iyZYtvu1NTU6V2MzU1BQB4whOeAMBOEKptj9DpdHyb3tuuyyuuuAKPe9zj8OlPfxqdTgfGGG8X/uIv/gJZlt3ka6dp6knPRz7yESwsLNyo888880zc4x73wMrKCl71qlcBsJOAV7ziFciyDA9+8IPxZ3/2Z/747du349vf/jYA4PTTT8fExMQe3ef2vvBgv4EJ2O/whS98wczOzprZ2Vnz61//eo/O+dWvfuXP+eIXv1j67sEPfrCZnZ0197nPfcxJJ51kLrroImOMMUop8/Wvf90ce+yxZnZ21jzjGc8onff73//e3P3udzezs7PmLW95i5mbm/Pfzc3Nma9+9avm5S9/+aqyvPa1rzWzs7PmpJNOMl/+8pdNt9s1xhizsrJiPvGJT5h73/veZnZ21nzpS18qnfeZz3zGzM7Omnvd615m27Zt5pxzzjFLS0v+3F27dpnl5WVz9NFHm9nZWfOjH/1obF1861vfMrOzs+be9763GQwGpe9e9KIXmfPOO8/s2LHDf9btds3nP/9588AHPtDMzs6a97///auuSWV72tOeNvaeBKrrH/7wh6XPFxcX/fVPPfVU8/Of/9wYY0ye5+YrX/mKud/97mdmZ2fNGWecseqaL3vZy8zs7Ky5733va+5
"text/plain": [
"<Figure size 600x600 with 3 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"gb_ny = gb.query(\"`long` > -74.2735 & `long` < -73.2336\")\n",
"\n",
"ny_map = Image.open(\"images/new-york-adjusted.png\").convert(\"LA\")\n",
"ny_map.putalpha(int((5/8) * 256))\n",
"\n",
"## Colormap stuff\n",
"color_array = plt.get_cmap('copper_r')(range(256))\n",
"\n",
"# Set the alpha level for each color. These will follow the graph of y=x^(1/10)\n",
"# which will make regions with fewer observations less visible than those with more\n",
"# observations. Additionally, we cap the alpha level to .5 so the map isn't hidden\n",
"color_array[:,-1] = np.array([np.power(x, 1/10) for x in np.arange(0, .5, step=(1/256)*.5)])\n",
"\n",
"# Construct the reusable colormap\n",
"copper_alpha = LinearSegmentedColormap.from_list(name='reds_alpha5',colors=color_array)\n",
"\n",
"ny_gb_density = sns.jointplot(data=gb_ny, x=\"long\", y=\"lat\", kind=\"hex\", cmap=copper_alpha, color=(1, .745, .4))\n",
"\n",
"plt.xlim((-74.2735, -73.4536))\n",
"plt.ylim((40.3520,41.0608))\n",
"\n",
"_ = ny_gb_density.ax_joint.imshow(ny_map, aspect=\"auto\", extent=[-74.2735, -73.4536, 40.3520, 41.0608])\n",
"\n",
"ny_gb_density.ax_joint.set(\n",
" xlabel=\"Longitude\",\n",
" ylabel=\"Latitude\"\n",
")\n",
"\n",
"ny_gb_density.figure.suptitle(\"Observational Density in NYC\")\n",
"ny_gb_density.figure.subplots_adjust(top=0.925)\n",
"\n",
"ny_gb_density.figure.savefig(\"./images/graphs/8-ny-gb-density.png\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2023-03-26 00:10:24 +00:00
"## Is there a correlation between geographical stratums and having same-sex partners?\n",
"\n",
"### Quantitatively measuring queerness\n",
"\n",
"Before we attempt to visualize queerness geographically, it's worth taking the time now to consider what that actually means.\n",
"\n",
"To begin, we must acknowledge the role statisticians have played presently and historically in systematically eliminating minorities. One local example of this is the way that Canada's Indian Act works to incrementally strip Indigenous people of their legal recognition of being Indigenous through the malitiously-named process of \"enfranchisement\"[^1], in a process many now refer to as \"statistical genocide.\" Discretely categorizing people enables oppression and marginalizes deviation. That second issue is particularly pertinent in the case of the queer community, which is predicated on \"bending rules,\" so to speak. For that reason, I'm hesitant to even use the phrase \"queer community,\" as it implicitly makes the assumption that the constituents of the so-called \"queer community\" have a universal experience, which is completely untrue.\n",
"\n",
"Somewhat depressingly, the article for which this dataset was produced admits the following:\n",
"\n",
"> Currently, theres no comprehensive way to quantitatively measure gayborhoods, or even where LGBTQ Americans live. Most of the existing data sticks to a narrow view (i.e. traditional marriage, the male/female gender binary) of the queer spectrum and “rainbow-washes” any intersectionality of race, ethnicity, class, gender, and sexuality. This project aims to paint a slightly more complete picture, combining several metrics to create a gayborhood index, but even then it admittedly underweights and undercounts areas with non-binary and minority populations. Still, this is some of the most complete data that we have. (More about the limitations in the methodology section.)[^2]\n",
"\n",
"Essentially, this dataset fails to represent queerness outside the context of monogamous partnerships between cisgender people (or at least, those who have been statistically represented as such). For this reason, this analysis seeks to be very upfront that it only explores \"same-sex\" partnerships.\n",
"\n",
"Data Analysts at The Pudding created the `TOTINDEX` column in the Gaybourhoods dataset in an attempt to cumulatively measure queerness in a given neighbourhood. Before we tear it appart and try to come up with something better, let's take a look at how this looks spatially in New York City, and compare it to how the spread changes when we only factor in the number of same-sex partnerships that reside there:\n",
"\n",
"[^1]: https://www.cbc.ca/radio/unreserved/how-the-indian-act-continues-to-impact-the-lives-of-first-nation-people-1.5614187\n",
"\n",
"[^2]: https://pudding.cool/2018/06/gayborhoods/"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABFEAAAH9CAYAAADS/+OVAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOx9Z4AUVdb2U1WdJjIkUREFdXtAchYJShDERQRFQQXFAJjQVZdXUFFXTKsgSjBhQlEUBCSIKEkRUEBEQBYBQXIOE7unu6vqvj+qzq1bPT3DzDADrnuf7/NdprrCjec895xzz1UYYwwSEhISEhISEhISEhISEhISEsVCPdMFkJCQkJCQkJCQkJCQkJCQkPhvgDSiSEhISEhISEhISEhISEhISJQA0ogiISEhISEhISEhISEhISEhUQJII4qEhISEhISEhISEhISEhIRECSCNKBISEhISEhISEhISEhISEhIlgDSiSEhISEhISEhISEhISEhISJQA0ogiISEhISEhISEhISEhISEhUQJII4qEhISEhISEhISEhISEhIRECSCNKBISEhISEhISEhISEhISEhIlgDSiSEhIlAqdOnVCZmYmVq1aVW7vHD9+PDIzMzF8+PBye2dJ3p2ZmYnMzEzs3b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NGoRwOAzAivTZu3cvxo8fj+XLl6NVq1alfudnn33GF62A1Y6maWLXrl3YtWsXFi9ejN69e8Pv9yM5ORnVqlXD8ePHYZqmay87gEJtCVh
"text/plain": [
"<Figure size 1300x500 with 2 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"figure, axes = plt.subplots(1,2, sharex=True, sharey=True, figsize=(13, 5))\n",
"figure.suptitle(\"Spatial distribution of Queer Comunities by Different Metrics\")\n",
"axes[0].set_title(\"Queerness by TOTINDEX\")\n",
"axes[1].set_title(\"Queerness by Same-Sex Partnerships\")\n",
"\n",
"sns.kdeplot(data=gb_ny, x=\"long\", y=\"lat\", weights=\"TOTINDEX\", color=\"orange\", fill=True, cmap=copper_alpha, ax=axes[0])\n",
"sns.kdeplot(data=gb_ny, x=\"long\", y=\"lat\", weights=\"SS_Index\", color=\"orange\", fill=True, cmap=copper_alpha, ax=axes[1])\n",
"\n",
"plt.xlim((-74.2735, -73.4536))\n",
"plt.ylim((40.3520,41.0608))\n",
"\n",
"for a in axes:\n",
" a.imshow(ny_map, aspect=\"auto\", extent=[-74.2735, -73.4536, 40.3520, 41.0608])\n",
" a.set_xlabel(\"Longitude\")\n",
" a.set_ylabel(\"Latitude\")\n",
" \n",
"figure.savefig(\"./images/graphs/9-ny-queer-metrics.png\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2023-03-26 00:10:24 +00:00
"The distinction is somewhat subtle but there remains a meaningful difference. It's clear that when we factor in gay bars and pride parades, we narrow our scope. This makes quite a bit of sense, as not all queer people frequent bars and not everyone has the privilege of celebrating their queerness. Going forward, we will measure the queerness of a neighbourhood based only on how many same-sex partnerships reside there.\n",
"\n",
"### Measuring gaybourhood clusteredness\n",
2023-03-26 00:10:24 +00:00
"To facilitate answering this research question, we've added an additional column to the gaybourhoods dataframe that discretely classifies neighbourhoods into 7 categories labeled `0` through `6`, with zero indicating there are very few same-sex partnerships and 6 indicating that there are many. The choice to divide the dataframe into seven categories was arbitrary, although inspired by Alfred Kinsey's research into the fluidity of human sexuality[^3]. Similarly to the Kinsey scale, our factor will be linear. The consequence of this is that the vast majority of the observations will be lumped into the lower categories. Nevertheless, this is a fair approximation that will make further analysis significantly easier.\n",
"\n",
2023-03-26 00:10:24 +00:00
"As seen below, virtually all observed neighbourhoods have a same-sex partner index of less than 25:\n",
"\n",
"[^3]: https://en.wikipedia.org/wiki/Kinsey_scale"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAowAAAHTCAYAAACtA0lpAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAABq5ElEQVR4nO3deXxM1+M+8Gcmm+wrIiG0dBJFRBJBrEkQak+tIWqvokp1oVqttpZaaq0lag8JGrtKEGoXPpZobVVqSYiSRVZZ7++P/Ga+xszcTDKTjef9eqWac869c+7JnZln7j33jkQQBAFERERERBpIK7oDRERERFS5MTASERERkSgGRiIiIiISxcBIRERERKIYGImIiIhIFAMjEREREYliYCQiIiIiUQyMRERERCSKgZGIiIiIRL22gdHf3x/+/v4V3Q2tuLq6IiQkpKK7oRc7d+6Eq6srdu7cWdFdKZGpU6fC1dUV8fHxFd0VrcTHx8PV1RVTp06t6K4QVWqxsbFwdXXFsmXLtF5m2bJlcHV1RWxsbBn2rHxUpfdCqtwM9bkyV1dXAICTkxOioqJgYmKi0sbf3x8JCQm4du0aDA1L//AhISE4f/48bt26Vep1VHX//vsvIiIicP78eSQkJCAzMxPm5uaoW7cuvL290a1bNzRu3Liiu0mVRE5ODsLCwhAVFYW7d+8iJycHNjY2qFGjBjw8PNClSxf4+PhUdDfL1OnTp7F161bExcUhNTUVpqamsLOzg6urK7y9vRESEgKJRFLR3VS8vr3MzMwMb731Fjp37oxhw4ahWrVqZfb4rq6u8PH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YsW8PT0hJGREW7fvo0dO3bg2LFjiIyMRM2aNQEAbdq0gYuLCw4ePIivvvoKlpaWSuuKjo5GamoqRowYoRJCDh06hJMnT6Jjx47w8fHBjRs3EB0djdjYWISHh+Ptt99WtH348CGCg4Px33//oWXLlujWrRseP36MqKgo/PHHH1i2bBn8/PxKO2RKZs2ahf/9739o37492rdvr3JEaf78+Th16hT8/PzQunVrxMbGYvv27bh//75KEDh27JjiU3JgYCCcnJxw7do1hIeHK04Z1qlTp9TbmZubi2HDhuHPP/+Em5sbevTogfT0dKxYsUJlfltxbGxsABR9YNDW//73P6xZswYtWrRA586dYWZmhvv37yM6OhpHjx5FeHg43NzcVJaTP1/q16+PPn36ICEhAYcPH0ZISAi2bduGUaNGwcLCAl27dlU8l0aPHo3o6GilU4B5eXkYO3YsTp06hbfeegvdu3eHiYkJYmNj8cMPPyAuLg7z58/XaltsbW0BFP0NCgoKtD6S+Ntvv2HGjBkwNjaGv78/HB0dcf/+fezYsQNHjx7F9u3bFX2ePXs2+vTpg/nz58Pb2xvvvvsuAODs2bNYvXo1GjRogG+++UarxxUjDwzycLt9+3YcOXIEzZs3h6+vLwoLC3Ht2jWsX78eJ06cwPbt22FhYaGynujoaJw8eRLt2rXDwIED8ejRIzRs2BATJkzA8uXL4ezsrHQE89XpCiV5XQSAadOmYefOnXB0dETnzp1hZWWFK1euYMmSJTh79izWr1+v8nqVmpqKAQMGwMzMDJ07d4ZEIoG9vT2ys7MxaNAgPHjwAK1bt4a/vz8EQcCjR48QExODwMBApeceUBSsf/31V3h4eKBfv3549OgRDh06hGHDhmH37t1Kr0linj9/jkGDBsHS0hJBQUFIT0/HwYMH8dlnn+HJkycqH9JLIy8vDyNHjsR///2Hdu3awcDAAEeOHMHChQuRm5urcjp31qxZ2Lx5M6pXr44BAwbA0NAQMTExiIuLQ25urto
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"ss_index_hist = sns.histplot(data=gb.query(\"`SS_Index` != 0\"), x=\"SS_Index\")\n",
"\n",
"_ = ss_index_hist.set(\n",
" title=\"National Gaybourhood Same-Sex Partnership Index Frequency\",\n",
" xlabel=\"Same-Sex Partnership Index\",\n",
" xlim=(0,30),\n",
")\n",
"\n",
"ss_index_hist.figure.savefig(\"./images/graphs/10-ss-index-hist.png\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As such, we will choose 25 as our threshold for the highest level of queerness in a single community, such that anything higher than it will recieve a rating of `6`."
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkMAAAHTCAYAAAAktxxFAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAABHcElEQVR4nO3deVhUdf//8dcgiLigKFrumTVg7vuSG0qaW+aSlUtqlpao6W33nVZ3dZtad2lmZamZZi6U+5a5pqmZS26ZS7elomBSBojgwjLn90df5ufIoDAMDHCej+vqKs45c+Z93vNheHXOZ85YDMMwBAAAYFJeni4AAADAkwhDAADA1AhDAADA1AhDAADA1AhDAADA1AhDAADA1AhDAADA1AhDAADA1AhDAADA1AhDkCQNGDBAQUFBni7Drc6ePauwsDA9+OCDCgoKUqNGjTxdkgN39fzDDz9UUFCQ9u7dm+vPnduCgoI0YMAAT5eRaa68Nma1d+9eBQUF6cMPP/R0KQVKfvud8RTCkBsFBQUpKChIISEhunHjhtNt2rVrp6CgIKWkpORydeaSmpqqsLAwfffdd2rbtq1GjBihoUOH3vFxvIZA9qUFm4z+CG/fvl316tVTnTp1tGXLllyuLm9Iex+JjIz0dCmQ5O3pAgqiCxcuaP78+Zn644ucERkZqV9//VV9+vTRm2++meXH58Zr+N///lfXrl3Lsf0DedHy5cv12muvqVixYvrkk0/UsGFDSVKdOnW0fv16BQQEeLhCmBFnhtysZMmSKlWqlGbPnq2YmBhPl2Naf/zxhySpXLlyWX5sbr2GFSpUUPXq1XNs/0BeM2vWLL388ssKDAzUokWL7EFIkvz8/FS9enWVLl3agxXCrAhDblakSBE9//zzunLlimbMmJGpx9zpWnm7du3Url07h2UrVqxQUFCQVqxYoe+//159+/ZV/fr11axZM40fP17x8fGSpOPHj2vYsGFq3Lix6tevr+eee+62p2WTkpI0bdo0tWvXTrVq1VJoaKg++ugjJSUlOd3+t99+07hx49SmTRvVqlVLLVq00NixY3X69Ol0244bN05BQUE6f/68FixYoG7duqlOnTqZvp79888/a+TIkWrevLlq1aqlkJAQvfHGG/bgkyYoKEj9+/eXJH300Uf2S1+ZnYvgymuY5siRIxo1apQefPBB1apVS23atNFrr72m6OjodNtmNG8nKSlJH374odq3b69atWqpXbt2mjZtmpKSku54/X/Dhg3q3bu36tatqyZNmmjMmDFOn/vm58rK6/3DDz9oyJAhatKkiWrVqqWOHTtqypQpunLlSrptnY3bNBnNpUk7vj///FOvvPKKWrVqpRo1amjFihUO28XExOjf//63WrZsqVq1aqlLly5avny50+ey2WwKDw9Xr169VL9+fdWrV0+9evXS4sWLZbPZsn2c0t9jc8iQIapfv74aNGigQYMG6dChQ063laQff/xRzz33nFq3bq1atWrpwQcfVJ8+ffTRRx9l+Jib3fyecejQIQ0aNEgNGzZU/fr1NWTIEB09etTp41JSUrRo0SL16dNHDRo0UN26dfXoo49q4cKF6XoRGRmpoKAgjRs3TmfOnNHo0aPVvHlzBQcHZ3kOlGEYmjhxot577z3dd999+vLLL3X//fdneEw3S/s9SUlJ0cyZM9WhQwf779a7777rdKxmpb/Xrl3TrFmz1L17d9WrV0/169fX448/rnXr1jlst3PnTgUFBWn8+PFOjzEpKUlNmzZV06ZNM/z9yYy034GsjPGkpCTNmDFDoaGh6d4zMpLZsXD+/Hk1atRITZo0UVRUlMM+rl69qk6dOqlGjRr5fl4cl8lyQL9+/bRo0SJ99dVXGjBggO65554ce65vv/1W27dvV9u2bfXEE0/o0KFDWrFihSIjIzV27Fj7m2Tv3r31v//9T9u2bVNkZKTWrFkjL6/0WfiFF17Q0aNH9fDDD8vb21tbt27Vhx9+qJ9//lmffPKJLBaLfdsdO3Zo5MiRSklJUUhIiKpUqaLo6Ght2rRJ27dv1xdffKGaNWume45Jkybpxx9/VJs2bdSmTRsVKlTojse5bds2jRw5UpLUsWNHVahQQceOHVN4eLi2bt2qxYsXq3LlypKkESNGKCoqSitXrlSTJk3UpEkTSbL/OzNceQ2XLVum1157TYULF1a7du109913KyIiQkuXLtW3336rJUuWqEKFCrfdh2EYGjlypLZv36577rlH/fv3V0pKilauXKlff/31to9dvHixvv32W7Vr106NGzfWTz/9pPXr1+vkyZNavXq1ChcunO4xWXm9v/zyS73xxhvy8/PTww8/rDJlymjfvn369NNPtW3bNoWHh8vf3/+OfbqTuLg4Pf744ypatKg6dOggi8WiMmXK2NfHx8frySefVOHChdWxY0clJSVpw4YNevnll+Xl5aUePXo47O+f//yn1q1bp/Lly6t3796yWCzasmWL/vOf/+jAgQOaOnWqw/ZZPc6DBw9q8ODBSk5O1kMPPaSqVavqxIkTGjBggJo1a5bu+Hbs2KFhw4apePHiateune666y7FxcXp9OnTWrx4sUaMGJHpXh05ckSzZs1SixYt1K9fP0VERGjz5s3av3+/5s6d6/ChgeTkZD333HPatWuXqlWrpq5du8rX11d79+7Vm2++qSNHjujdd99N9xznzp1Tnz59dM8996hbt266fv26ihcvnukak5KS9NJLL2n9+vWqX7++Zs6cqVKlSmX68WnGjh2rAwcOqFWrVmrTpo127NihOXPmKCYmRm+99ZZ9u6z0Nz4+XgMHDtTx48dVs2ZN9erVSzabTbt27dLYsWN16tQpjRkzRpLUsmVLValSRd98841efvlllShRwqG+jRs3Ki4uTk8//bTT37WsyMoYNwxDo0eP1tatW1WlShX1799fycnJWr58uf73v/853X9WxkLlypU1ceJEvfDCCxo7dqwWLlwob++/o8N//vMfnT59WiNHjlTTpk2zdcweZ8BtrFar0apVK8MwDOObb74xrFarERYW5rBNSEiIYbVajeTkZPuyPXv2GFar1fjggw+c7jckJMQICQlxWLZ8+XLDarUaNWrUMPbu3WtfnpqaagwaNMiwWq1G48aNjdWrVzs8bvz48YbVajU2b97ssLx///6G1Wo1OnToYMTFxdmXX79+3ejTp49htVqNlStX2pfHxcUZjRo1Mpo0aWKcOnXKYV+//PKLUa9ePePRRx91WP7SSy8ZVqvVaNmypXHu3Dmnx+pMQkKC0aRJEyM4ONjYv3+/w7pZs2YZVqvVGDx4sMPyO/U0I66+hqdPnzZq1qxphIaGGhcvXnTYfvfu3UZwcLAxfPhwh+VpPb/ZypUrDavVavTt29e4ceOGffnly5eNjh07Glar1ejfv7/DYz744APDarUa9evXN06ePOmw7h//+IdhtVqNr7/+2ulzZ/b1joyMNGrWrGnUr1/f+PXXXx329frrrxtWq9V49dVX0/Xp1nF7a8179uxxWG61Wg2r1Wr885//dOjvretffvllIyUlxb781KlTRo0aNYxOnTo5bL927VrDarUajz76qJGQkGBfnpiYaPTo0cOwWq3GmjVrXD5Om81mf11u/Z36/PPP7fXefJwjRowwrFarceLEiXTH99dffznt163SxrfVajUWLFjgsG7z5s2G1Wo1HnroISM1NdW+PK3nEyZMcOhdSkqK0/eF8+fP259j6tSpmarr1vp69Ohhfz8aNmyYce3atTs+5tbf2bSx2qNHDyM2Nta+PDEx0QgNDTWCg4ONP/74w748K/1Ne0+aPXu2w/Lr168bTz/9tBEUFGQcP37cvnzOnDlOe35znadPn87wGG+W9j5y/vx5h+VZHeNr1qwxrFar0adPH+P69ev25bGxsUb79u1v+56R2bFgGP9//E+ZMsUwDMNYsWKFYbVajQEDBjiMs/yKy2Q55OGHH1b9+vW1efNm/fjjjzn2PF26dHE44+Hl5aXu3btLku6//3498sgjDts/+uijkqSTJ0863d/zzz+vkiVL2n/29fXVP/7
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"gb_kinsey_bar = sns.barplot(\n",
" data=gb.groupby(\"kinsey\").aggregate(len).reset_index().drop(0),\n",
" x=\"SS_Index\", y=\"kinsey\", palette=\"Pastel2\", orient=\"h\"\n",
")\n",
"\n",
"_ = gb_kinsey_bar.set(\n",
2023-04-05 21:04:50 +00:00
" title=\"Number of Neighbourhoods per Kinsey Index\",\n",
" ylabel=\"Kinsey Index\",\n",
" xlabel=\"Count\"\n",
")\n",
"\n",
"gb_kinsey_bar.figure.savefig(\"./images/graphs/11-gb-kinsey-bar.png\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Excluded from the above graph is all neighbourhoods with a Kinsey index of 0, which won't be relevant to our next line of inquiry. It shouldn't come as a major suprise that as an under-represented minority group, most recorded neighbourhoods would have a Kinsey index of `0`. We now turn our attention to measuring their clusteredness.\n",
"\n",
2023-03-26 00:10:24 +00:00
"Without trying to quantify this question any further, we can preliminarily visualize the clusteredness of queer populations as we did before using topological diagrams. We predict from personal experience that queer communities will tend to cluster together, representing crests in their respective diagrams:"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABJ4AAApGCAYAAAApQQH1AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOx9d5wVRdb2U33T5MAMAgImdBAwIGACFUFExbCiYpZlcXVxV11f9zWuYV/z6n7rymLYgBnRlSDBBCqgiIAERUEEDOSByXnm3ttd3x/Vp7r6zp0EM6LueX7rcufe7urq6uoTnnPqlJBSSjAYDAaDwWAwGAwGg8FgMBjtDGtfd4DBYDAYDAaDwWAwGAwGg/HzBBNPDAaDwWAwGAwGg8FgMBiMDgETTwwGg8FgMBgMBoPBYDAYjA4BE08MBoPBYDAYDAaDwWAwGIwOARNPDAaDwWAwGAwGg8FgMBiMDgETTwwGg8FgMBgMBoPBYDAYjA4B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o1W44IIL2BhOwJIlSwAAp512Gq655pq9amv37t24+uqrsWHDBgBAly5dcOGFF2LgwIHIzc1FeXk5Vq5cienTp6OwsBAzZszA+vXr8e9//7vV0VxGY3zxxReYMGECiouLAQDdu3fHOeecg2OOOQZ5eXmIxWLYtWsXlixZgvnz56O8vBzPPPMMzjzzTPTp02cf957RVhx//PHtRig98sgjeOSRR9qlrR8Ddu7cieXLlwMA0tLSUFtbi1mzZjHxxPhRYcWKFfj973+PWCyGQCCAs88+G8OGDUOPHj0QCARQXFyMdevW4aOPPsLq1atb3W59fT3effddAN78f+edd3DXXXchHA531O0wGIx9BCaeGIw9xPTp0zXplJeXh7/97W847rjjGh03ePBgXHHFFdiwYQMefvhhlJaW/tBdZTB+Nti1axcA4OCDD96rduLxOG688UZNOp199tm4//77kZ6e7jtuyJAhuPrqq3H33XfjzTffxLp163DTTTfhhRde4GWze4CioiIf6XTdddfht7/9bVInY9SoUbj99tvx3HPP4R//+McP3VUGo8Mxa9YsSCkRCoVw22234d5778WmTZvwxRdf4Mgjj9zX3WMwAKiMMCKd/v3vf2Pw4MGNjhk6dCiuu+46bN++HZ988kmr2p0/fz5qamoAAHfddRfuvPNOVFRU4IMPPsCZZ57ZrvfAYDD2PdhqZjD2ALt27cL9998PQEVpXnrppaSkk4mCggJMnjwZ48eP/yG6yGD8LBGLxQAAweDexU2ee+45HZk9+eST8dhjjzUinQjp6el47LHHcNJJJwFQNSlefvnlvbr+fyvuueceTTr9/ve/x0033dRsZDsjIwM33HADnn/+eV7iyPjZYdasWQCUDBo9ejQyMzN93zMY+xq7du3Cl19+CQAYMWJEUtLJRPfu3XHRRRe1qu033ngDgKpJdeGFF+qAEn3PYDB+XuCMJwZjD/D888+jrq4OAHDjjTeiV69erTrPsiz84he/aPL3FStW4LXXXsPKlStRVFSESCSCHj16YOjQofjlL3+JTp06JT0vWd2gt956C6+99hq+/vpr1NbWolu3bjjttNNw7bXXIicnp8W+Llq0CHPmzMHq1atRUlIC27bRuXNn9O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ioQCQSQV5eHrp164YTTzwRI0aMwKGHHtro3O+++05fd/v27YjFYsjJyUFeXh769u2Lk08+GSNGjGjT0qzEeXbHHXc0movNyWbHcdpkmyQbj9mzZ+Odd97B2rVrUV5ejvT0dBxyyCEYOXIkLrvssh9NPbudO3fqzwceeGC7tbt7926dGXXeeefpf5944gksXrwYpaWlTdq
"text/plain": [
"<Figure size 1500x3000 with 15 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"figure, axes = plt.subplots(5,3, figsize=(15, 30))\n",
"figure.suptitle(\"Concentration of Queer Communities Across the USA\", fontsize=20)\n",
"figure.subplots_adjust(top=0.95)\n",
"\n",
"# Atlanda\n",
"for i, city in enumerate(CITIES):\n",
" ax = axes[(i - i % 3)//3][i % 3]\n",
" sns.kdeplot(\n",
" data=gb[(gb[\"long\"] > city[\"pos\"][0]) & (gb[\"long\"] < city[\"pos\"][1]) & (gb[\"lat\"] > city[\"pos\"][2]) & (gb[\"lat\"] < city[\"pos\"][3])],\n",
" x=\"long\", y=\"lat\", weights=\"SS_Index\", fill=True, cmap=copper_alpha, alpha=.7, ax=ax\n",
" )\n",
" ax.imshow(\n",
" Image.open(f\"images/{'-'.join(city['name'].lower().split())}.png\").convert(\"LA\"),\n",
" aspect=\"auto\", extent=city[\"pos\"], alpha=.5\n",
" )\n",
" ax.set_title(city[\"name\"], fontsize=18)\n",
" \n",
" ax.get_xaxis().set_ticks([])\n",
" ax.get_yaxis().set_ticks([])\n",
" ax.set_xlabel(None)\n",
" ax.set_ylabel(None)\n",
" \n",
"figure.figure.savefig(\"./images/graphs/12-queer-concentration-nationally.png\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As expected, in all 15 cities studied, we see a relatively sharp \"peak\" in gay residents in one area. Further, neighbourhoods tend to get less queer radially outwards of this peak.\n",
"\n",
2023-03-26 00:10:24 +00:00
"Another interesting observation is that with the exception of Chicago and Miami, all of the queerest communities in each city tend to be clustered around the geographical city centre. This is in line with conventional wisdom that the inner-city tends to be inhabited primarily by poor people and other marginalized groups, while the more privileged groups tend to live outside the city, commuting in for work.\n",
"\n",
"Our use of KDE plots to illustrate this phenomenon works, but isn't ideal. It'd debateable (and outside the scope of this project) whether or not queerness is discrete or continuous in a spatial environment. The observations collected in the gaybourhoods dataset certainly are discrete, however, and by visualizing them using a KDE plot we are effectively \"undoing\" that discretization. While this may be a meaningful action to take, it will inevitably introduce error. We deem this acceptable because our goal is to illustrate the clusteredness of queer communities on a macro level.\n",
"\n",
"Another way we can quantify the clusteredness of queer communities more numerically is to assess how likely a given neighbourhood is to be surrounded by neighbourhoods with a Kinsey index that is equal to or higher than its own. To do this, we algorithmically select a small group of observations in the vicinity of a given observation and calculate the mean Kinsey Index of that group, assigning it as a new column to the original observation as its \"Neighbourhood Kinsey Index.\"\n",
"\n",
"This approach is loosely inspired by differential calculus, in how the differential of a function is considered the \"instantaneous\" rate of change, or what the rate of change of the function would be about a point.\n",
"\n",
"While it has proven to be sufficient, there is one notable limitation. Our data fundamentally discrete, and there is a limit to how small the smallest possible neighbourhood about an observation can be."
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABBEAAAI2CAYAAAAGghDfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd3xT5f4H8E/SlTSdTJFRClJaLIgXKAqIslEUKMpSQFFEZOi9iojzqter6E+WKCAXRYagjLJXsaAyhMooqxQUSoECZXRndOX8/ijnmDRJm92k/bxfL1+WM59zkrR5vud5vl+ZIAgCiIiIiIiIiIiqIK/uBhARERERERGRd2AQgYiIiIiIiIiswiACEREREREREVmFQQQiIiIiIiIisgqDCERERERERERkFQYRiIiIiIiIiMgqDCIQERERERERkVUYRCAiIiIiIiIiqzCIQERERERERERWYRCBiKgK06dPR+vWrTF9+vTqbgp5iHnz5qF169YYPXp0dTeFiIiI4PjfZv5ttx6DCFQl8QMl/rd169Yq9xk/frzRPleuXHFDSz1DQkKCdN3R0dFITU2tdHtx24SEBJN1Yue1Z8+elR7j66+/lo7zyiuvoLi4GABw5cqVSo9fW4j3YN68eRa3ycnJwdChQ9G6dWvExsZi27ZtbmxhzWD43q9Nn3kiVzL8G3zfffchKyvL4raGv/MPHTpksn706NFVfkHW6/V47733pOP897//hSAIAIBDhw5VevyaKDs7GwsWLMDIkSPRuXNn3HvvvejcuTMGDBiACRMmYNGiRTh69Gh1N9Nj1bT7Z/h3zvC/2NhYdO3aFc8//zzWrFmDkpKSamnfvHnzMG/ePP4NJpfzre4GkPdJSEjAgAEDLK7PysrCvn373NgizyUIAmbOnIlvv/3WZcf/9NNPsXTpUgDAsGHD8OGHH0IuZ3zQFllZWXj++efx119/QalUYt68eXjooYek9fXr10dkZCTq169fja0kotpOp9Ph66+/xkcffeSS4xcXF2PatGnYvn07AOCVV17BpEmTXHIub/D777/jn//8J3Jzc6VlgYGBKC0txV9//YW//voLe/bsAQCcPXu2mlrpuWr6/QsPD4ePjw8AQKPR4NatW7h16xb279+PH3/8Ed999x1CQ0Pd2qavvvoKABAXF4cmTZq49dw1QXh4OCIjI9GoUaPqborHYxCBrBYeHo6ioiIcOHAA169fx1133WV2u40bN6KsrAyNGzdGZmamm1vpefbt24fff/8dDz74oFOPW1ZWhnfffVcaYTBu3Di88cYbTj1HbZCRkYGxY8ciMzMTISEh+Oabb/CPf/zDaJvXX38dr7/+ejW1kIjob+vWrcPYsWMRGRnp1ONqtVpMnjwZ+/btg0wmw3vvvYdnnnnGqefwJlevXsXEiROh0WjQuHFjTJo0CX369EFISAgAoKCgAMePH8fu3buxZcuWam6t56kN92/t2rVGHfXLly9jzpw52LJlC06dOoX33nsPX375ZTW2kGw1atQojBo1qrqb4RX4uJKsFhgYiH79+kGv11c6NH7dunUAgCFDhriraR6rR48eAICZM2dKw0Gdobi4GK+++qr0OkydOpUBBDukpaXhmWeeQWZmJurXr48VK1aYBBCIiDxBo0aN0Lp1a5SWlmL27NlOPXZ+fj7Gjh2Lffv2wc/PD//3f/9XqwMIAPDTTz9Bo9HAz88PK1aswJNPPil1gAEgODgY3bp1w/vvv4/ffvutGlvqmWrj/WvatCm++OILdOzYEQCQmJiImzdvVnOriFyDIxHIJkOGDMH69euxfv16TJw40WT94cOHcfHiRTRt2lT6JVqVX375BevWrUNKSgpycnKgVCoRFRWFAQMG4KmnnoK/v7/JPnl5eUhMTMS+fftw4cIFZGVlQavVol69evjHP/6B0aNHo3379mbPN2/ePHz11VeIi4vD8uXL8fvvv2PJkiU4ceIE1Go1mjRpggEDBuDFF19EQECATfenotdeew2//vorTp48iR07duDRRx916HgAoFarMWnSJPz+++/w8fHBhx9+iKFDhzp8XHN69uyJzMxMfPrpp+jbty+++eYbJCYm4tq1a1AqlejQoQNeeukl3HfffZUe58iRI1i1ahWOHDmCW7duwd/fH5GRkejbty+eeeYZqFQqk32mT5+O9evXIz4+Hp9++inWrl2LhIQEXLhwAbm5ufj0008dClQdPXoUL730EvLz89GkSRMsWbIEzZo1M7utYVtmzJhhtG706NFITk7G5MmTMXnyZKxZswZr1qzB+fPnIQgCoqKi8PTTT2PQoEFmj11aWop169Zhy5YtOHfuHAoLCxEUFISwsDDExMSga9euFl/fK1euYOnSpThw4ACuXr0KvV6PRo0aoVu3bnj++edx9913G23/r3/9C9u2bUP37t3xv//9z+K9ycjIQL9+/SAIApYtW4bOnTtXdiudxpbfBbdv30b37t1RWlqK+fPno1evXhaPO3fuXMyfPx/NmjXDrl27TNbb8/4kcje5XI7XX38d48ePx86dO3HixAm0a9fO4ePevHkTL7zwAs6ePQuFQoEvv/wSDz/8sBNa/Lddu3Zh8uTJ8PPzw969exEeHm5x22eeeQaHDx/Gk08+iU8++URafv36dXz33XfYv38/MjMzUVpairCwMDRo0AAdO3bE448/7pT7ITpz5gwAICYmxuR3aUUKhc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KlCnQarWIiorCt99+iwYNGjh0zLKyMkyaNAlJSUnw9fWFQqGAWq1GSkoKUlJSkJGRgVdeecVkn/Hjx2P//v3SsuDgYGg0GuTm5uLixYvYvn272SDCpk2b8M4770hJNP39/SGXy5Geno709HQkJCTgyy+/RLdu3aR9RowYgW3btmHfvn24evWqxS92a9asgSAIaN68uVsCCPb8Lqhbty66deuGX375BRs3brQYRBAEAZs2bQIAk0COM96fRO708MMPIy4uDsn
"text/plain": [
"<Figure size 1200x600 with 2 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig, axes = plt.subplots(1, 2, figsize=(12, 6))\n",
"mean_kinsey = gb.groupby(\"kinsey\").mean().reset_index()\n",
"\n",
"mean_nk_bar = sns.barplot(data=mean_kinsey,\n",
" x=\"kinsey\", y=\"neighbourhood_kinsey\", ax=axes[0])\n",
"\n",
"mean_nk_scatter = sns.scatterplot(data=gb, x=\"SS_Index\", y=\"neighbourhood_kinsey\", marker=\"x\", ax=axes[1])\n",
"\n",
"mean_nk_bar.set_title(\"Mean NKI per Kinsey Level\", fontsize=18)\n",
"mean_nk_bar.set_xlabel(\"Kinsey Index\", fontsize=15)\n",
"mean_nk_bar.set_ylabel(\"Mean NKI\", fontsize=15)\n",
"\n",
"mean_nk_scatter.set(ylabel=None, xlim=(0,30), ylim=(0,3))\n",
"mean_nk_scatter.set_xlabel(\"Same-Sex Partnership Index\", fontsize=15)\n",
"_=mean_nk_scatter.set_title(\"NKI vs. Same-Sex Partnerships\", fontsize=18)\n",
"\n",
"fig.savefig(\"./images/graphs/13-neighbourhood-kinsey-comparison.png\")"
]
},
2023-03-26 00:10:24 +00:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The graph on the left shows that neighbourhoods with a higher Kinsey index tend to have a higher Neighbourhood Kinsey Index on average, which strongly suggests that queer neighbourhoods tend to cluster together. Interestingly, this is less the case with neighbourhoods with a Kinsey index of 6. This makes sense when we consider that the number of neighbourhoods that fall into that category is small, and we've defined it such that nothing can be higher.\n",
"\n",
"Neighbourhoods with a KI of 1 are about three times more likely to be surrounded by other queer neighbourhoods than neighbourhoods with a KI of 0. This further illustrates the fact that queer communities tend to cluster together.\n",
"\n",
"The graph on the right illustrates the same fact by measuring NKI versus the Same-Sex Partnership Index. While the results are consistent, this graph reveals that there's quite a bit of variance.\n",
"\n",
"All together, it's very clear that there is a strong coorelation between geological strata and wanting/having same sex partners."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Is there a correlation between political alignment & living in neighbourhoods with large quantities of LGBT people?\n",
"\n",
"To tackle this question, we need to unify the gaybourhoods dataset with the election data from the 2012 US presidential election. To accomplish this, we used our `nearest_neighbour` algorithm to locate the county closest to each observation in the gaybourhoods dataset and create an additional column connecting the gaybourhoods to their county's election outcome."
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABJ4AAApGCAYAAAApQQH1AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd3gUVdvG79nZvukJCYTQS+gdkY+uNFGQF1BBBLvYe1fAXnjt4GtFRQREkK4gSgdp0kFCDzWk1+07M98fZ8+ZmWRTSSh6ftfFRXZ3dvbMzCnPuZ/nPEdQFEUBh8PhcDgcDofD4XA4HA6HU80YLnUBOBwOh8PhcDgcDofD4XA4/0y48MThcDgcDofD4XA4HA6Hw6kRuPDE4XA4HA6Hw+FwOBwOh8OpEbjwxOFwOBwOh8PhcDgcDofDqRG48MThcDgcDofD4XA4HA6Hw6kRuPDE4XA4HA6Hw+FwOBwOh8OpEbjwxOFwOBwOh8PhcDgcDofDqRG48MThcDgcDofD4XA4HA6Hw6kRuPDE4XA4HA6Hw+FwOBwOh8OpEbjwxOFw/lUkJyezf2fOnLnUxeFUkAULFrD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X39FmzZt8NFHH6FevXoVLnNWVhaefvppbN68ucLfqWnMZjPuuecePPvsswBIJMaiRYtw7733lvqdnJwcvPLKK/jtt99KfJaVlYWsrCzs2LEDX3/9NV566aUKGx2URYsW4ZVXXoHb7da9f+LECZw4cQL
"text/plain": [
"<Figure size 1500x3000 with 15 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"figure, axes = plt.subplots(5,3, figsize=(15, 30))\n",
"figure.suptitle(\"Queer Density and Democrat Turnout Across America\", fontsize=25)\n",
"figure.subplots_adjust(top=0.95)\n",
"\n",
"for i, city in enumerate(CITIES):\n",
" ax = axes[(i - i % 3)//3][i % 3]\n",
" sns.kdeplot(\n",
" data=select_region(gb, *city[\"pos\"]),\n",
" x=\"long\", y=\"lat\", weights=\"SS_Index\", color=\"orange\", ax=ax\n",
" )\n",
" sns.kdeplot(\n",
" data=select_region(gb, *city[\"pos\"]),\n",
" x=\"long\", y=\"lat\", weights=\"percent_democrat\", color=\"blue\", ax=ax\n",
" )\n",
" \n",
" ax.imshow(\n",
" Image.open(f\"images/{'-'.join(city['name'].lower().split())}.png\").convert(\"LA\"),\n",
" aspect=\"auto\", extent=city[\"pos\"], alpha=.4\n",
" )\n",
" ax.set_title(city[\"name\"], fontsize=20)\n",
" \n",
" ax.get_xaxis().set_ticks([])\n",
" ax.get_yaxis().set_ticks([])\n",
" ax.set_xlabel(None)\n",
" ax.set_ylabel(None)\n",
"\n",
"orange_patch = mpatches.Patch(color='orange', label='SS Index')\n",
"blue_patch = mpatches.Patch(color='blue', label='Democrat Turnout')\n",
"_ = axes[0][0].legend(handles=[orange_patch, blue_patch])\n",
"\n",
"figure.savefig(\"./images/graphs/14-queer-vs-democrat-density.png\")"
]
},
2023-03-26 00:10:24 +00:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"With the exception of Washington DC, Miami and Chicago, the peaks in the respective topological maps almost completely overlap, implying a relationship between queerness in a given community and voter turnout for the Democratic Party. This aligns with conventional wisdom once again in that urban queer people tend to support liberals more often than conservatives in elections.\n",
"\n",
"Similar to before, using a weighted KDE plot to illustrate election results can be somewhat misleading in certain cases, as some cities contain fewer counties than others.\n",
"\n",
"Alternatively, we can use our Kinsey index once again to assess this relationship more categorically:"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkAAAAHTCAYAAADPgKdGAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAABiX0lEQVR4nO3dd1xT9/4/8FfCkC0ouHCPAAqigBsHbouKExc4qlWv29a2or0darW1rrrXFQdKHeBCRdS6FQdatYqjblDRCsgQWTm/P/wlX0OCQggEOK/n4+GjzTknJ+/zycnhlfP5nBOJIAgCiIiIiEREqu8CiIiIiIoaAxARERGJDgMQERERiQ4DEBEREYkOAxARERGJDgMQERERiQ4DEBEREYkOAxARERGJDgMQERERiQ4DEBGJXmhoKBwcHBAaGqrvUvLkwoULcHBwwLJly/RdSqni4OAAf39/fZdBRcRQ3wVQ8eXg4KDy2MjICBYWFqhcuTLq16+Pzp07w9PTEwYGBnqqsPTw9/fHxYsXcefOnTwtHxoaioCAgHy9Rl7XXZJNnz4du3fvxrFjx1C1alV9l5MnFy5cwNChQ9G0aVNs2bJFbf6JEycwZcoUyOVyLFq0CB07dtRDlfrVvn17xMbGlqj3lYo/BiD6pAkTJgAAsrOzkZycjHv37mHv3r3YtWsXnJ2dsWDBAtSqVUvPVYqLk5OT8n1RiI2Nxe7du2Fvb4/evXvrqTLSpZCQEHz//fcwNzfHqlWr4O7uDgBo2LAhDh48CBsbGz1XSFRyMQDRJ02cOFFt2r///ovZs2cjPDwcI0aMQEhICMqXL6+H6sTJyckJTk5OKtMuXLigDECa3jMqWdasWYNFixahUqVKWL9+PerVq6ecZ2pqijp16uixOqKSj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w/Tp37pzKvAULFggymUxYu3atyvTPP/9ckMlkwsqVK1WmR0VFCU5OTkLTpk2FlJQU5XRFO0dGRqq9/tOnTwWZTCZ8++23KtO//fZbQSaTCU+fPtW4rblRbI9MJhP+/PNPlXkbN24UZDKZMHToUJXp3t7egrOzsxAfH68y/cmTJ4KDg4MwYMCAPL224v3p3bu3cl8fM2aMkJaW9snn5HxPFftR7969hYSEBOX01NRUoWPHjoKjo6Pw8uVL5fQJEyYIMplMiI6OVnuND/d5Qfi/ts35vr579074/PPPBQcHB+HWrVvK6evXrxdkMpmwZcsWtXUr6nzw4EGu2/ghLy8vje+r4j2bMWOGkJWVpZx+7949wcnJSejWrZvK8vv27RNkMpng6+srvHv3Tjk9ISFB6NChg8bPj2I/nDVrlsprZGVlaTz+CIIg/PDDD4JMJhMWLFggCIIghIaGCjKZTPD391c57pB+sQuMCsTY2Fj5DTUhIQEAcPv2bVy8eBGdO3eGt7e3yvJWVlaYOHEi0tPTcfjwYbX1eXt7q3yjlkql8PHxAQDUq1cPPXv2VFm+V69eytdUuHLlCh48eIDGjRurLf/ZZ5/B3d0dDx8+RFRUFID3XV/btm2DiYkJfvrpJ7VvpMbGxipnMhR8fX1Rv359je1SvXp1tWnGxsYYMmQIsrKycP78eY3PK246dOiANm3a5Dr/s88+Q4sWLVSmKc7s3bhxQzntxYsXOHPmDKpUqYJRo0apLO/m5gZvb28kJibiyJEjOqw+/5o3b652FsrPzw/Vq1dHZGSkSrfGoEGDkJGRoex2U9ixYwcEQcj32Z+bN2/i3LlzqFWrFpYvXw4TExOtt2PatGkqZ47MzMzQo0cPyOVyjd2NZcqUUZv24T6fkJCAffv2wdnZGV988YXac7/++msIgoD9+/crp/fp0wdlypRRng1TePDgAS5evIhmzZrp5OIJU1NTBAQEqFyNWrd
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"gb_pol = gb.groupby(\"kinsey\").mean().reset_index()\n",
"\n",
"gb_pol[\"percent_democrat\"] = gb_pol[\"percent_democrat\"] * 100\n",
"\n",
"kinsey_democrat_plot = sns.barplot(data=gb_pol, orient=\"h\", x=\"percent_democrat\", y=\"kinsey\", palette=\"Pastel2\")\n",
"_ = kinsey_democrat_plot.set(\n",
" xlabel=\"Percentage of the Population who Voted Democrat in 2012\",\n",
" ylabel=\"Kinsey Index\",\n",
" title=\"Democrat Turnout by Kinsey Index\",\n",
2023-03-26 00:10:24 +00:00
" xlim=(50,80)\n",
")\n",
"\n",
"kinsey_democrat_plot.figure.savefig(\"./images/graphs/15-kinsey-democrat-plot.png\")"
]
2023-03-26 00:10:24 +00:00
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"While this once again reveals that queerer communities tend to vote blue more often, it is worth noting here that our data only ranges between 60% and 75%. That is a meaningful different (one so meaningful that it ultimately won an election) but it is useful to keep in mind how substantial this data is.\n",
"\n",
"Of course, in the 2012 presidential election, the Democrats won, so it's not suprising that across the nation, people tended to vote for the Democrats more than they did for the Republicans. Nevertheless, it's still clear that communities with a larger queer population tend to vote more blue than others."
]
2023-02-01 01:23:45 +00:00
}
],
"metadata": {
2023-02-16 00:29:26 +00:00
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
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-04-05 21:04:50 +00:00
"version": "3.10.10"
},
"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
}