{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Nat Scott" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 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", "\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", "\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", "- 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" ] }, { "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": [ "
\n", " | SS_Index | \n", "TOTINDEX | \n", "lat | \n", "long | \n", "kinsey | \n", "percent_democrat | \n", "neighbourhood_kinsey | \n", "
---|---|---|---|---|---|---|---|
0 | \n", "55.012669 | \n", "67.077054 | \n", "34.093828 | \n", "-118.381697 | \n", "6 | \n", "0.456450 | \n", "1.132075 | \n", "
1 | \n", "58.412517 | \n", "61.866815 | \n", "37.758057 | \n", "-122.435410 | \n", "6 | \n", "0.742633 | \n", "2.533333 | \n", "
2 | \n", "30.731192 | \n", "37.908747 | \n", "40.742039 | \n", "-74.000620 | \n", "6 | \n", "0.775215 | \n", "1.091667 | \n", "
3 | \n", "21.995808 | \n", "37.530067 | \n", "40.734012 | \n", "-74.006746 | \n", "6 | \n", "0.794248 | \n", "1.101695 | \n", "
4 | \n", "21.284224 | \n", "35.843573 | \n", "37.773134 | \n", "-122.411167 | \n", "5 | \n", "0.742633 | \n", "2.533333 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
2323 | \n", "0.000000 | \n", "0.000000 | \n", "45.528666 | \n", "-122.678981 | \n", "0 | \n", "0.753689 | \n", "1.708333 | \n", "
2324 | \n", "0.000000 | \n", "0.000000 | \n", "47.606211 | \n", "-122.333792 | \n", "0 | \n", "0.545340 | \n", "2.148148 | \n", "
2325 | \n", "0.000000 | \n", "0.000000 | \n", "47.449678 | \n", "-122.307657 | \n", "0 | \n", "0.543670 | \n", "1.357143 | \n", "
2326 | \n", "0.000000 | \n", "0.000000 | \n", "47.604569 | \n", "-122.335359 | \n", "0 | \n", "0.545340 | \n", "2.148148 | \n", "
2327 | \n", "0.000000 | \n", "0.000000 | \n", "47.649339 | \n", "-122.310294 | \n", "0 | \n", "0.545340 | \n", "1.714286 | \n", "
2328 rows × 7 columns
\n", "\n", " | county | \n", "lat | \n", "long | \n", "percent | \n", "
---|---|---|---|---|
0 | \n", "Autauga AL | \n", "32.532237 | \n", "-86.646439 | \n", "0.265878 | \n", "
1 | \n", "Baldwin AL | \n", "30.659218 | \n", "-87.746067 | \n", "0.215894 | \n", "
2 | \n", "Barbour AL | \n", "31.870253 | \n", "-85.405103 | \n", "0.513685 | \n", "
3 | \n", "Bibb AL | \n", "33.015893 | \n", "-87.127148 | \n", "0.261520 | \n", "
4 | \n", "Blount AL | \n", "33.977357 | \n", "-86.566440 | \n", "0.123719 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
2879 | \n", "Sweetwater WY | \n", "41.660328 | \n", "-108.875677 | \n", "0.282569 | \n", "
2880 | \n", "Teton WY | \n", "44.048662 | \n", "-110.426087 | \n", "0.541957 | \n", "
2881 | \n", "Uinta WY | \n", "41.284726 | \n", "-110.558947 | \n", "0.190655 | \n", "
2882 | \n", "Washakie WY | \n", "43.878830 | \n", "-107.669052 | \n", "0.201318 | \n", "
2883 | \n", "Weston WY | \n", "43.846213 | \n", "-104.570020 | \n", "0.125633 | \n", "
2884 rows × 4 columns
\n", "