diff --git a/data-exploration/.ipynb_checkpoints/Prener Data Exploration-checkpoint.ipynb b/data-exploration/.ipynb_checkpoints/Prener Data Exploration-checkpoint.ipynb
new file mode 100644
index 0000000..af6be96
--- /dev/null
+++ b/data-exploration/.ipynb_checkpoints/Prener Data Exploration-checkpoint.ipynb
@@ -0,0 +1,800 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 43,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Enter password: ········\n"
+ ]
+ }
+ ],
+ "source": [
+ "from arcgis.gis import GIS\n",
+ "\n",
+ "gis = GIS(\"https://www.arcgis.com/home/\", \"gregbrunner_slugis\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "data = \"prcl_shape.zip\"\n",
+ "stl = gis.content.add({\"title\":\"St. Louis parcel data from STL's Open Data site\", \"tags\":\"St. Louis, parcels\"}, data)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "published_stl = stl.publish()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "
\n",
+ "\n",
+ "
\n",
+ "
\n",
+ " "
+ ],
+ "text/plain": [
+ "- "
+ ]
+ },
+ "execution_count": 4,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "published_stl"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "0e211e68d11b4e969754569b6af3046d",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "MapView(basemaps=['dark-gray', 'dark-gray-vector', 'gray', 'gray-vector', 'hybrid', 'national-geographic', 'oc…"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "stl_map = gis.map('St. Louis, MO')\n",
+ "stl_map"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "stl_map.add_layer(published_stl)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Ignore this :)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "high_estimate = '../data-2017/parcel/high-estimate/parcel-data-2017-highEstimate.csv'\n",
+ "h_est = gis.content.add({\"title\":\"high_estimate\", \"tags\":\"St. Louis, parcels, vacancy\"}, high_estimate)\n",
+ "\n",
+ "from arcgis.features import analysis\n",
+ "\n",
+ "enriched_parcels = analysis.join_features(target_layer=published_stl, join_layer=h_est, attribute_relationship='HANDLE', gis=gis)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## This didn't work. Let's just join dataframes..."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 45,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#from arcgis.features import FeatureLayer\n",
+ "\n",
+ "#url = 'https://services1.arcgis.com/g2TonOxuRkIqSOFx/arcgis/rest/services/prcl_shape/FeatureServer/0'\n",
+ "\n",
+ "#slugis = GIS(\"https://www.arcgis.com/home/\", \"gregbrunner_slugis\")\n",
+ "\n",
+ "#parcel_fl = FeatureLayer(url, gis = gis)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from arcgis.features import FeatureLayer\n",
+ "\n",
+ "parcel_fl = FeatureLayer(url = published_stl.url, gis = gis)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 47,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "parcels_sdf = published_stl.layers[0].query().df\n",
+ "#parcels_sdf = parcel_fl.query().df"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 48,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "127758"
+ ]
+ },
+ "execution_count": 48,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "len(parcels_sdf)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 49,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "dtype('O')"
+ ]
+ },
+ "execution_count": 49,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "parcels_sdf.HANDLE.dtype"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 50,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "parcels_sdf['H'] = parcels_sdf['HANDLE'].astype(float)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 51,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "dtype('float64')"
+ ]
+ },
+ "execution_count": 51,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "parcels_sdf.H.dtype"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 52,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import pandas as pd"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 53,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "low_estimate = '../data-2017/parcel/low-estimate/parcel-data-2017-lowEstimate.csv'\n",
+ "high_estimate = '../data-2017/parcel/high-estimate/parcel-data-2017-highEstimate.csv'"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 54,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "estimate = high_estimate"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 55,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "h_est_df = pd.read_csv(estimate)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 56,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "h_est_df = h_est_df.rename(columns={ 'handle' : \"H\"})"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 57,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "dtype('float64')"
+ ]
+ },
+ "execution_count": 57,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "h_est_df.H.dtype"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 58,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "48013"
+ ]
+ },
+ "execution_count": 58,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "len(h_est_df)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 59,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " H | \n",
+ " vacantBinary | \n",
+ " cityStatus | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 1.000100e+10 | \n",
+ " True | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 1.000100e+10 | \n",
+ " True | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 1.000100e+10 | \n",
+ " True | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 1.001400e+10 | \n",
+ " True | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 1.001400e+10 | \n",
+ " True | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " H vacantBinary cityStatus\n",
+ "0 1.000100e+10 True False\n",
+ "1 1.000100e+10 True False\n",
+ "2 1.000100e+10 True False\n",
+ "3 1.001400e+10 True False\n",
+ "4 1.001400e+10 True False"
+ ]
+ },
+ "execution_count": 59,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "h_est_df.head()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 60,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from arcgis.features import SpatialDataFrame as spd"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 61,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "merged_data = spd.merge(parcels_sdf, h_est_df, how = 'left', left_on='H', right_on='H')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 62,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " FID | \n",
+ " HANDLE | \n",
+ " Shape__Area | \n",
+ " Shape__Length | \n",
+ " SHAPE | \n",
+ " H | \n",
+ " vacantBinary | \n",
+ " cityStatus | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 1 | \n",
+ " 10329000045 | \n",
+ " 1830.843750 | \n",
+ " 179.595654 | \n",
+ " {'rings': [[[-10039885.1163153, 4671794.922912... | \n",
+ " 1.032900e+10 | \n",
+ " NaN | \n",
+ " NaN | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 2 | \n",
+ " 10001000005 | \n",
+ " 1020.195312 | \n",
+ " 130.846919 | \n",
+ " {'rings': [[[-10039556.032893, 4667225.8128700... | \n",
+ " 1.000100e+10 | \n",
+ " True | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 3 | \n",
+ " 10329000075 | \n",
+ " 1830.839844 | \n",
+ " 179.595194 | \n",
+ " {'rings': [[[-10039873.7565212, 4671765.761943... | \n",
+ " 1.032900e+10 | \n",
+ " NaN | \n",
+ " NaN | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 4 | \n",
+ " 10001000010 | \n",
+ " 2003.324219 | \n",
+ " 273.216695 | \n",
+ " {'rings': [[[-10039533.5723971, 4667298.017724... | \n",
+ " 1.000100e+10 | \n",
+ " True | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 5 | \n",
+ " 10329000105 | \n",
+ " 1830.824219 | \n",
+ " 179.594684 | \n",
+ " {'rings': [[[-10039862.3967913, 4671736.601044... | \n",
+ " 1.032900e+10 | \n",
+ " NaN | \n",
+ " NaN | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " FID HANDLE Shape__Area Shape__Length \\\n",
+ "0 1 10329000045 1830.843750 179.595654 \n",
+ "1 2 10001000005 1020.195312 130.846919 \n",
+ "2 3 10329000075 1830.839844 179.595194 \n",
+ "3 4 10001000010 2003.324219 273.216695 \n",
+ "4 5 10329000105 1830.824219 179.594684 \n",
+ "\n",
+ " SHAPE H \\\n",
+ "0 {'rings': [[[-10039885.1163153, 4671794.922912... 1.032900e+10 \n",
+ "1 {'rings': [[[-10039556.032893, 4667225.8128700... 1.000100e+10 \n",
+ "2 {'rings': [[[-10039873.7565212, 4671765.761943... 1.032900e+10 \n",
+ "3 {'rings': [[[-10039533.5723971, 4667298.017724... 1.000100e+10 \n",
+ "4 {'rings': [[[-10039862.3967913, 4671736.601044... 1.032900e+10 \n",
+ "\n",
+ " vacantBinary cityStatus \n",
+ "0 NaN NaN \n",
+ "1 True False \n",
+ "2 NaN NaN \n",
+ "3 True False \n",
+ "4 NaN NaN "
+ ]
+ },
+ "execution_count": 62,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "merged_data.head()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 35,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "31473"
+ ]
+ },
+ "execution_count": 35,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "len(merged_data[merged_data['vacantBinary']==True])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 36,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "empty_parcels = merged_data[merged_data['vacantBinary']==True].copy()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 37,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " FID | \n",
+ " HANDLE | \n",
+ " Shape__Area | \n",
+ " Shape__Length | \n",
+ " SHAPE | \n",
+ " H | \n",
+ " vacantBinary | \n",
+ " cityStatus | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 2 | \n",
+ " 10001000005 | \n",
+ " 1020.195312 | \n",
+ " 130.846919 | \n",
+ " {'rings': [[[-10039556.032893, 4667225.8128700... | \n",
+ " 1.000100e+10 | \n",
+ " True | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 4 | \n",
+ " 10001000010 | \n",
+ " 2003.324219 | \n",
+ " 273.216695 | \n",
+ " {'rings': [[[-10039533.5723971, 4667298.017724... | \n",
+ " 1.000100e+10 | \n",
+ " True | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 7 | \n",
+ " 10330000030 | \n",
+ " 244.117188 | \n",
+ " 78.191878 | \n",
+ " {'rings': [[[-10039983.5732021, 4671883.351409... | \n",
+ " 1.033000e+10 | \n",
+ " True | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 8 | \n",
+ " 10001000032 | \n",
+ " 323.976562 | \n",
+ " 88.823036 | \n",
+ " {'rings': [[[-10039503.905549, 4667209.6188938... | \n",
+ " 1.000100e+10 | \n",
+ " True | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 14 | \n",
+ " 10014000005 | \n",
+ " 1417.808594 | \n",
+ " 176.194846 | \n",
+ " {'rings': [[[-10039171.9315976, 4668734.117673... | \n",
+ " 1.001400e+10 | \n",
+ " True | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " FID HANDLE Shape__Area Shape__Length \\\n",
+ "0 2 10001000005 1020.195312 130.846919 \n",
+ "1 4 10001000010 2003.324219 273.216695 \n",
+ "2 7 10330000030 244.117188 78.191878 \n",
+ "3 8 10001000032 323.976562 88.823036 \n",
+ "4 14 10014000005 1417.808594 176.194846 \n",
+ "\n",
+ " SHAPE H \\\n",
+ "0 {'rings': [[[-10039556.032893, 4667225.8128700... 1.000100e+10 \n",
+ "1 {'rings': [[[-10039533.5723971, 4667298.017724... 1.000100e+10 \n",
+ "2 {'rings': [[[-10039983.5732021, 4671883.351409... 1.033000e+10 \n",
+ "3 {'rings': [[[-10039503.905549, 4667209.6188938... 1.000100e+10 \n",
+ "4 {'rings': [[[-10039171.9315976, 4668734.117673... 1.001400e+10 \n",
+ "\n",
+ " vacantBinary cityStatus \n",
+ "0 True False \n",
+ "1 True False \n",
+ "2 True False \n",
+ "3 True False \n",
+ "4 True False "
+ ]
+ },
+ "execution_count": 37,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "empty_parcels.reset_index(inplace=True, drop=True)\n",
+ "empty_parcels.head()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 63,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'C:\\\\Users\\\\greg6750\\\\Documents\\\\IPython Notebooks\\\\vacancy-data\\\\data-exploration\\\\vacancy.gdb\\\\high_estimate_all'"
+ ]
+ },
+ "execution_count": 63,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "merged_data.to_featureclass(out_location=r'C:\\Users\\greg6750\\Documents\\IPython Notebooks\\vacancy-data\\data-exploration\\vacancy.gdb', \n",
+ " out_name=\"high_estimate_all\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 65,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#merged_data[merged_data['vacantBinary']==True].to_featureclass(out_location=r'C:\\Users\\greg6750\\Documents\\IPython Notebooks\\vacancy-data\\data-exploration\\vacancy.gdb', \n",
+ "# out_name=\"vacant_low_estimate\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 64,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "fs = gis.content.import_data(merged_data, title='STL Vacancy - High Estimate')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "## Extra"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#sdf = sdf[sdf.SHAPE.notna()].copy()"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.6.5"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/data-exploration/Prener Data Exploration.ipynb b/data-exploration/Prener Data Exploration.ipynb
new file mode 100644
index 0000000..af6be96
--- /dev/null
+++ b/data-exploration/Prener Data Exploration.ipynb
@@ -0,0 +1,800 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 43,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Enter password: ········\n"
+ ]
+ }
+ ],
+ "source": [
+ "from arcgis.gis import GIS\n",
+ "\n",
+ "gis = GIS(\"https://www.arcgis.com/home/\", \"gregbrunner_slugis\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "data = \"prcl_shape.zip\"\n",
+ "stl = gis.content.add({\"title\":\"St. Louis parcel data from STL's Open Data site\", \"tags\":\"St. Louis, parcels\"}, data)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "published_stl = stl.publish()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
\n",
+ "\n",
+ "
\n",
+ "
\n",
+ " "
+ ],
+ "text/plain": [
+ "- "
+ ]
+ },
+ "execution_count": 4,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "published_stl"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "0e211e68d11b4e969754569b6af3046d",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "MapView(basemaps=['dark-gray', 'dark-gray-vector', 'gray', 'gray-vector', 'hybrid', 'national-geographic', 'oc…"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "stl_map = gis.map('St. Louis, MO')\n",
+ "stl_map"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "stl_map.add_layer(published_stl)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Ignore this :)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "high_estimate = '../data-2017/parcel/high-estimate/parcel-data-2017-highEstimate.csv'\n",
+ "h_est = gis.content.add({\"title\":\"high_estimate\", \"tags\":\"St. Louis, parcels, vacancy\"}, high_estimate)\n",
+ "\n",
+ "from arcgis.features import analysis\n",
+ "\n",
+ "enriched_parcels = analysis.join_features(target_layer=published_stl, join_layer=h_est, attribute_relationship='HANDLE', gis=gis)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## This didn't work. Let's just join dataframes..."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 45,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#from arcgis.features import FeatureLayer\n",
+ "\n",
+ "#url = 'https://services1.arcgis.com/g2TonOxuRkIqSOFx/arcgis/rest/services/prcl_shape/FeatureServer/0'\n",
+ "\n",
+ "#slugis = GIS(\"https://www.arcgis.com/home/\", \"gregbrunner_slugis\")\n",
+ "\n",
+ "#parcel_fl = FeatureLayer(url, gis = gis)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from arcgis.features import FeatureLayer\n",
+ "\n",
+ "parcel_fl = FeatureLayer(url = published_stl.url, gis = gis)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 47,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "parcels_sdf = published_stl.layers[0].query().df\n",
+ "#parcels_sdf = parcel_fl.query().df"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 48,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "127758"
+ ]
+ },
+ "execution_count": 48,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "len(parcels_sdf)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 49,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "dtype('O')"
+ ]
+ },
+ "execution_count": 49,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "parcels_sdf.HANDLE.dtype"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 50,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "parcels_sdf['H'] = parcels_sdf['HANDLE'].astype(float)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 51,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "dtype('float64')"
+ ]
+ },
+ "execution_count": 51,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "parcels_sdf.H.dtype"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 52,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import pandas as pd"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 53,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "low_estimate = '../data-2017/parcel/low-estimate/parcel-data-2017-lowEstimate.csv'\n",
+ "high_estimate = '../data-2017/parcel/high-estimate/parcel-data-2017-highEstimate.csv'"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 54,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "estimate = high_estimate"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 55,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "h_est_df = pd.read_csv(estimate)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 56,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "h_est_df = h_est_df.rename(columns={ 'handle' : \"H\"})"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 57,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "dtype('float64')"
+ ]
+ },
+ "execution_count": 57,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "h_est_df.H.dtype"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 58,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "48013"
+ ]
+ },
+ "execution_count": 58,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "len(h_est_df)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 59,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " H | \n",
+ " vacantBinary | \n",
+ " cityStatus | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 1.000100e+10 | \n",
+ " True | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 1.000100e+10 | \n",
+ " True | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 1.000100e+10 | \n",
+ " True | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 1.001400e+10 | \n",
+ " True | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 1.001400e+10 | \n",
+ " True | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " H vacantBinary cityStatus\n",
+ "0 1.000100e+10 True False\n",
+ "1 1.000100e+10 True False\n",
+ "2 1.000100e+10 True False\n",
+ "3 1.001400e+10 True False\n",
+ "4 1.001400e+10 True False"
+ ]
+ },
+ "execution_count": 59,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "h_est_df.head()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 60,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from arcgis.features import SpatialDataFrame as spd"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 61,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "merged_data = spd.merge(parcels_sdf, h_est_df, how = 'left', left_on='H', right_on='H')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 62,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " FID | \n",
+ " HANDLE | \n",
+ " Shape__Area | \n",
+ " Shape__Length | \n",
+ " SHAPE | \n",
+ " H | \n",
+ " vacantBinary | \n",
+ " cityStatus | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 1 | \n",
+ " 10329000045 | \n",
+ " 1830.843750 | \n",
+ " 179.595654 | \n",
+ " {'rings': [[[-10039885.1163153, 4671794.922912... | \n",
+ " 1.032900e+10 | \n",
+ " NaN | \n",
+ " NaN | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 2 | \n",
+ " 10001000005 | \n",
+ " 1020.195312 | \n",
+ " 130.846919 | \n",
+ " {'rings': [[[-10039556.032893, 4667225.8128700... | \n",
+ " 1.000100e+10 | \n",
+ " True | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 3 | \n",
+ " 10329000075 | \n",
+ " 1830.839844 | \n",
+ " 179.595194 | \n",
+ " {'rings': [[[-10039873.7565212, 4671765.761943... | \n",
+ " 1.032900e+10 | \n",
+ " NaN | \n",
+ " NaN | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 4 | \n",
+ " 10001000010 | \n",
+ " 2003.324219 | \n",
+ " 273.216695 | \n",
+ " {'rings': [[[-10039533.5723971, 4667298.017724... | \n",
+ " 1.000100e+10 | \n",
+ " True | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 5 | \n",
+ " 10329000105 | \n",
+ " 1830.824219 | \n",
+ " 179.594684 | \n",
+ " {'rings': [[[-10039862.3967913, 4671736.601044... | \n",
+ " 1.032900e+10 | \n",
+ " NaN | \n",
+ " NaN | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " FID HANDLE Shape__Area Shape__Length \\\n",
+ "0 1 10329000045 1830.843750 179.595654 \n",
+ "1 2 10001000005 1020.195312 130.846919 \n",
+ "2 3 10329000075 1830.839844 179.595194 \n",
+ "3 4 10001000010 2003.324219 273.216695 \n",
+ "4 5 10329000105 1830.824219 179.594684 \n",
+ "\n",
+ " SHAPE H \\\n",
+ "0 {'rings': [[[-10039885.1163153, 4671794.922912... 1.032900e+10 \n",
+ "1 {'rings': [[[-10039556.032893, 4667225.8128700... 1.000100e+10 \n",
+ "2 {'rings': [[[-10039873.7565212, 4671765.761943... 1.032900e+10 \n",
+ "3 {'rings': [[[-10039533.5723971, 4667298.017724... 1.000100e+10 \n",
+ "4 {'rings': [[[-10039862.3967913, 4671736.601044... 1.032900e+10 \n",
+ "\n",
+ " vacantBinary cityStatus \n",
+ "0 NaN NaN \n",
+ "1 True False \n",
+ "2 NaN NaN \n",
+ "3 True False \n",
+ "4 NaN NaN "
+ ]
+ },
+ "execution_count": 62,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "merged_data.head()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 35,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "31473"
+ ]
+ },
+ "execution_count": 35,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "len(merged_data[merged_data['vacantBinary']==True])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 36,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "empty_parcels = merged_data[merged_data['vacantBinary']==True].copy()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 37,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " FID | \n",
+ " HANDLE | \n",
+ " Shape__Area | \n",
+ " Shape__Length | \n",
+ " SHAPE | \n",
+ " H | \n",
+ " vacantBinary | \n",
+ " cityStatus | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 2 | \n",
+ " 10001000005 | \n",
+ " 1020.195312 | \n",
+ " 130.846919 | \n",
+ " {'rings': [[[-10039556.032893, 4667225.8128700... | \n",
+ " 1.000100e+10 | \n",
+ " True | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 4 | \n",
+ " 10001000010 | \n",
+ " 2003.324219 | \n",
+ " 273.216695 | \n",
+ " {'rings': [[[-10039533.5723971, 4667298.017724... | \n",
+ " 1.000100e+10 | \n",
+ " True | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 7 | \n",
+ " 10330000030 | \n",
+ " 244.117188 | \n",
+ " 78.191878 | \n",
+ " {'rings': [[[-10039983.5732021, 4671883.351409... | \n",
+ " 1.033000e+10 | \n",
+ " True | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 8 | \n",
+ " 10001000032 | \n",
+ " 323.976562 | \n",
+ " 88.823036 | \n",
+ " {'rings': [[[-10039503.905549, 4667209.6188938... | \n",
+ " 1.000100e+10 | \n",
+ " True | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 14 | \n",
+ " 10014000005 | \n",
+ " 1417.808594 | \n",
+ " 176.194846 | \n",
+ " {'rings': [[[-10039171.9315976, 4668734.117673... | \n",
+ " 1.001400e+10 | \n",
+ " True | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " FID HANDLE Shape__Area Shape__Length \\\n",
+ "0 2 10001000005 1020.195312 130.846919 \n",
+ "1 4 10001000010 2003.324219 273.216695 \n",
+ "2 7 10330000030 244.117188 78.191878 \n",
+ "3 8 10001000032 323.976562 88.823036 \n",
+ "4 14 10014000005 1417.808594 176.194846 \n",
+ "\n",
+ " SHAPE H \\\n",
+ "0 {'rings': [[[-10039556.032893, 4667225.8128700... 1.000100e+10 \n",
+ "1 {'rings': [[[-10039533.5723971, 4667298.017724... 1.000100e+10 \n",
+ "2 {'rings': [[[-10039983.5732021, 4671883.351409... 1.033000e+10 \n",
+ "3 {'rings': [[[-10039503.905549, 4667209.6188938... 1.000100e+10 \n",
+ "4 {'rings': [[[-10039171.9315976, 4668734.117673... 1.001400e+10 \n",
+ "\n",
+ " vacantBinary cityStatus \n",
+ "0 True False \n",
+ "1 True False \n",
+ "2 True False \n",
+ "3 True False \n",
+ "4 True False "
+ ]
+ },
+ "execution_count": 37,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "empty_parcels.reset_index(inplace=True, drop=True)\n",
+ "empty_parcels.head()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 63,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'C:\\\\Users\\\\greg6750\\\\Documents\\\\IPython Notebooks\\\\vacancy-data\\\\data-exploration\\\\vacancy.gdb\\\\high_estimate_all'"
+ ]
+ },
+ "execution_count": 63,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "merged_data.to_featureclass(out_location=r'C:\\Users\\greg6750\\Documents\\IPython Notebooks\\vacancy-data\\data-exploration\\vacancy.gdb', \n",
+ " out_name=\"high_estimate_all\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 65,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#merged_data[merged_data['vacantBinary']==True].to_featureclass(out_location=r'C:\\Users\\greg6750\\Documents\\IPython Notebooks\\vacancy-data\\data-exploration\\vacancy.gdb', \n",
+ "# out_name=\"vacant_low_estimate\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 64,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "fs = gis.content.import_data(merged_data, title='STL Vacancy - High Estimate')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "## Extra"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#sdf = sdf[sdf.SHAPE.notna()].copy()"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.6.5"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}