Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aflaxman/223b4811f56edc4d6da07b0d730449bf to your computer and use it in GitHub Desktop.
Save aflaxman/223b4811f56edc4d6da07b0d730449bf to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Fri Mar 13 14:19:06 PDT 2020\r\n"
]
}
],
"source": [
"import numpy as np, matplotlib.pyplot as plt, pandas as pd\n",
"pd.set_option('display.max_rows', 8)\n",
"!date\n",
"\n",
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Washington State Nursing Home Populations by Age\n",
"\n",
"To better model the spread of CoV-SARS-2 and COVID-19 in Washington State in 2019, I am putting together estimates of the number of individuals in nursing homes, stratified by age.\n",
"\n",
"This brings together data from two open sources: (1) the [Medicare Minimum Data Set (MDS) 3.0](https://www.cms.gov/Research-Statistics-Data-and-Systems/Computer-Data-and-Systems/Minimum-Data-Set-3-0-Public-Reports/Minimum-Data-Set-3-0-Frequency-Report), which provides a measurement of the age structure and total number of people in Washington State who are in skilled nursing facilities; and (2) the Washington Aging and Long-Term Support Administration (ALTSA) [Nursing Facility and Reports webpage](https://www.dshs.wa.gov/altsa/management-services-division/nursing-facility-rates-and-reports)."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"n_total = 16_323 # from MDS 3.0 2019Q4 report, table RSAGE, row for Washington"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0-30 58.7628\n",
"31-64 2582.2986\n",
"65-74 3778.7745\n",
"75-84 4655.3196\n",
"85-95 4483.9281\n",
"96+ 763.9164\n",
"dtype: float64"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"age_group_pct = {\n",
" '0-30': 0.36,\n",
" '31-64': 15.82,\n",
" '65-74': 23.15,\n",
" '75-84': 28.52,\n",
" '85-95': 27.47,\n",
" '96+': 4.68\n",
"} # also from MDS 3.0 2019Q4 report, table RSAGE, row for Washington\n",
"\n",
"age_frac = pd.Series(age_group_pct)/100\n",
"\n",
"n_by_age = n_total * age_frac\n",
"n_by_age"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"scrolled": true
},
"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>Vendor Name</th>\n",
" <th>License Number</th>\n",
" <th>Vendor ID</th>\n",
" <th>NPI</th>\n",
" <th>P1</th>\n",
" <th>Effective Date</th>\n",
" <th>Location ID</th>\n",
" <th>City</th>\n",
" <th>Bed Count</th>\n",
" <th>Medicaid Cost Report Year</th>\n",
" <th>Medicaid Days</th>\n",
" <th>DC</th>\n",
" <th>ID</th>\n",
" <th>FR</th>\n",
" <th>QE</th>\n",
" <th>MW</th>\n",
" <th>TL</th>\n",
" <th>SA</th>\n",
" <th>TR</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>ADVANCED POST ACUTE</td>\n",
" <td>1544</td>\n",
" <td>4115441</td>\n",
" <td>1467909465</td>\n",
" <td>207922800</td>\n",
" <td>2020-01-01</td>\n",
" <td>32400</td>\n",
" <td>AUBURN</td>\n",
" <td>96</td>\n",
" <td>18</td>\n",
" <td>13640</td>\n",
" <td>153.08</td>\n",
" <td>48.06</td>\n",
" <td>11.79</td>\n",
" <td>5.45</td>\n",
" <td>0.76</td>\n",
" <td>219.14</td>\n",
" <td>23</td>\n",
" <td>242.14</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>ALASKA GARDENS HEALTH AND REHABILITATION CENTER</td>\n",
" <td>1603</td>\n",
" <td>4116031</td>\n",
" <td>1659326338</td>\n",
" <td>101557400</td>\n",
" <td>2020-02-01</td>\n",
" <td>40350</td>\n",
" <td>TACOMA</td>\n",
" <td>123</td>\n",
" <td>18</td>\n",
" <td>24108</td>\n",
" <td>146.25</td>\n",
" <td>48.06</td>\n",
" <td>14.82</td>\n",
" <td>5.45</td>\n",
" <td>0.76</td>\n",
" <td>215.34</td>\n",
" <td>23</td>\n",
" <td>238.34</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>ALDERCREST HEALTH &amp; REHABILITATION CENTER</td>\n",
" <td>1557</td>\n",
" <td>4115571</td>\n",
" <td>1295249431</td>\n",
" <td>209216500</td>\n",
" <td>2020-01-01</td>\n",
" <td>21300</td>\n",
" <td>EDMONDS</td>\n",
" <td>128</td>\n",
" <td>18</td>\n",
" <td>24164</td>\n",
" <td>163.69</td>\n",
" <td>48.06</td>\n",
" <td>8.89</td>\n",
" <td>0.00</td>\n",
" <td>0.76</td>\n",
" <td>221.40</td>\n",
" <td>23</td>\n",
" <td>244.40</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>ALDERWOOD MANOR</td>\n",
" <td>1102</td>\n",
" <td>4111027</td>\n",
" <td>1245284835</td>\n",
" <td>100583400</td>\n",
" <td>2020-01-01</td>\n",
" <td>33200</td>\n",
" <td>SPOKANE</td>\n",
" <td>85</td>\n",
" <td>18</td>\n",
" <td>15557</td>\n",
" <td>149.85</td>\n",
" <td>48.06</td>\n",
" <td>15.59</td>\n",
" <td>5.45</td>\n",
" <td>0.76</td>\n",
" <td>219.71</td>\n",
" <td>23</td>\n",
" <td>242.71</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",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\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>192</th>\n",
" <td>WHITMAN HEALTH AND REHABILITATION CENTER</td>\n",
" <td>1609</td>\n",
" <td>4116091</td>\n",
" <td>1265427397</td>\n",
" <td>100624800</td>\n",
" <td>2020-02-01</td>\n",
" <td>6400</td>\n",
" <td>COLFAX</td>\n",
" <td>55</td>\n",
" <td>18</td>\n",
" <td>9039</td>\n",
" <td>151.34</td>\n",
" <td>48.06</td>\n",
" <td>15.31</td>\n",
" <td>0.00</td>\n",
" <td>0.76</td>\n",
" <td>215.47</td>\n",
" <td>23</td>\n",
" <td>238.47</td>\n",
" </tr>\n",
" <tr>\n",
" <th>193</th>\n",
" <td>WILLAPA HARBOR HEALTH &amp; REHAB</td>\n",
" <td>1357</td>\n",
" <td>4113577</td>\n",
" <td>1659365922</td>\n",
" <td>101564200</td>\n",
" <td>2020-01-01</td>\n",
" <td>25100</td>\n",
" <td>RAYMOND</td>\n",
" <td>60</td>\n",
" <td>18</td>\n",
" <td>7830</td>\n",
" <td>166.24</td>\n",
" <td>48.06</td>\n",
" <td>6.65</td>\n",
" <td>0.00</td>\n",
" <td>0.76</td>\n",
" <td>221.71</td>\n",
" <td>23</td>\n",
" <td>244.71</td>\n",
" </tr>\n",
" <tr>\n",
" <th>194</th>\n",
" <td>WILLOW SPRINGS CARE AND REHABILITATION</td>\n",
" <td>1392</td>\n",
" <td>4113924</td>\n",
" <td>1609835990</td>\n",
" <td>101438800</td>\n",
" <td>2020-01-01</td>\n",
" <td>10300</td>\n",
" <td>YAKIMA</td>\n",
" <td>75</td>\n",
" <td>18</td>\n",
" <td>15207</td>\n",
" <td>123.85</td>\n",
" <td>48.06</td>\n",
" <td>17.06</td>\n",
" <td>5.45</td>\n",
" <td>0.76</td>\n",
" <td>195.18</td>\n",
" <td>23</td>\n",
" <td>218.18</td>\n",
" </tr>\n",
" <tr>\n",
" <th>195</th>\n",
" <td>WOODLAND CONVALESCENT CENTER</td>\n",
" <td>749</td>\n",
" <td>4174900</td>\n",
" <td>1063483337</td>\n",
" <td>100154500</td>\n",
" <td>2020-01-01</td>\n",
" <td>21400</td>\n",
" <td>WOODLAND</td>\n",
" <td>62</td>\n",
" <td>18</td>\n",
" <td>14273</td>\n",
" <td>140.96</td>\n",
" <td>48.06</td>\n",
" <td>11.06</td>\n",
" <td>8.18</td>\n",
" <td>0.76</td>\n",
" <td>209.02</td>\n",
" <td>23</td>\n",
" <td>232.02</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>196 rows × 19 columns</p>\n",
"</div>"
],
"text/plain": [
" Vendor Name License Number \\\n",
"0 ADVANCED POST ACUTE 1544 \n",
"1 ALASKA GARDENS HEALTH AND REHABILITATION CENTER 1603 \n",
"2 ALDERCREST HEALTH & REHABILITATION CENTER 1557 \n",
"3 ALDERWOOD MANOR 1102 \n",
".. ... ... \n",
"192 WHITMAN HEALTH AND REHABILITATION CENTER 1609 \n",
"193 WILLAPA HARBOR HEALTH & REHAB 1357 \n",
"194 WILLOW SPRINGS CARE AND REHABILITATION 1392 \n",
"195 WOODLAND CONVALESCENT CENTER 749 \n",
"\n",
" Vendor ID NPI P1 Effective Date Location ID City \\\n",
"0 4115441 1467909465 207922800 2020-01-01 32400 AUBURN \n",
"1 4116031 1659326338 101557400 2020-02-01 40350 TACOMA \n",
"2 4115571 1295249431 209216500 2020-01-01 21300 EDMONDS \n",
"3 4111027 1245284835 100583400 2020-01-01 33200 SPOKANE \n",
".. ... ... ... ... ... ... \n",
"192 4116091 1265427397 100624800 2020-02-01 6400 COLFAX \n",
"193 4113577 1659365922 101564200 2020-01-01 25100 RAYMOND \n",
"194 4113924 1609835990 101438800 2020-01-01 10300 YAKIMA \n",
"195 4174900 1063483337 100154500 2020-01-01 21400 WOODLAND \n",
"\n",
" Bed Count Medicaid Cost Report Year Medicaid Days DC ID \\\n",
"0 96 18 13640 153.08 48.06 \n",
"1 123 18 24108 146.25 48.06 \n",
"2 128 18 24164 163.69 48.06 \n",
"3 85 18 15557 149.85 48.06 \n",
".. ... ... ... ... ... \n",
"192 55 18 9039 151.34 48.06 \n",
"193 60 18 7830 166.24 48.06 \n",
"194 75 18 15207 123.85 48.06 \n",
"195 62 18 14273 140.96 48.06 \n",
"\n",
" FR QE MW TL SA TR \n",
"0 11.79 5.45 0.76 219.14 23 242.14 \n",
"1 14.82 5.45 0.76 215.34 23 238.34 \n",
"2 8.89 0.00 0.76 221.40 23 244.40 \n",
"3 15.59 5.45 0.76 219.71 23 242.71 \n",
".. ... ... ... ... .. ... \n",
"192 15.31 0.00 0.76 215.47 23 238.47 \n",
"193 6.65 0.00 0.76 221.71 23 244.71 \n",
"194 17.06 5.45 0.76 195.18 23 218.18 \n",
"195 11.06 8.18 0.76 209.02 23 232.02 \n",
"\n",
"[196 rows x 19 columns]"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# from ALTSA Nursing Facility and Reports spreadsheet, get beds per facility\n",
"fname = '/home/j/Project/simulation_science/covid/data/altsa_nursing_facility_rates_and_reports-2-1-20.xls'\n",
"df_beds = pd.read_excel(fname, header=6)\n",
"df_beds"
]
},
{
"cell_type": "code",
"execution_count": 7,
"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>Vendor Name</th>\n",
" <th>City</th>\n",
" <th>n_0-30</th>\n",
" <th>n_31-64</th>\n",
" <th>n_65-74</th>\n",
" <th>n_75-84</th>\n",
" <th>n_85-95</th>\n",
" <th>n_96+</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>ADVANCED POST ACUTE</td>\n",
" <td>AUBURN</td>\n",
" <td>0.291808</td>\n",
" <td>12.823333</td>\n",
" <td>18.764864</td>\n",
" <td>23.117664</td>\n",
" <td>22.266558</td>\n",
" <td>3.793502</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>ALASKA GARDENS HEALTH AND REHABILITATION CENTER</td>\n",
" <td>TACOMA</td>\n",
" <td>0.373879</td>\n",
" <td>16.429895</td>\n",
" <td>24.042482</td>\n",
" <td>29.619507</td>\n",
" <td>28.529027</td>\n",
" <td>4.860424</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>ALDERCREST HEALTH &amp; REHABILITATION CENTER</td>\n",
" <td>EDMONDS</td>\n",
" <td>0.389077</td>\n",
" <td>17.097777</td>\n",
" <td>25.019819</td>\n",
" <td>30.823552</td>\n",
" <td>29.688744</td>\n",
" <td>5.058002</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>ALDERWOOD MANOR</td>\n",
" <td>SPOKANE</td>\n",
" <td>0.258372</td>\n",
" <td>11.353992</td>\n",
" <td>16.614723</td>\n",
" <td>20.468765</td>\n",
" <td>19.715181</td>\n",
" <td>3.358830</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",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>192</th>\n",
" <td>WHITMAN HEALTH AND REHABILITATION CENTER</td>\n",
" <td>COLFAX</td>\n",
" <td>0.167182</td>\n",
" <td>7.346701</td>\n",
" <td>10.750703</td>\n",
" <td>13.244495</td>\n",
" <td>12.756882</td>\n",
" <td>2.173360</td>\n",
" </tr>\n",
" <tr>\n",
" <th>193</th>\n",
" <td>WILLAPA HARBOR HEALTH &amp; REHAB</td>\n",
" <td>RAYMOND</td>\n",
" <td>0.182380</td>\n",
" <td>8.014583</td>\n",
" <td>11.728040</td>\n",
" <td>14.448540</td>\n",
" <td>13.916599</td>\n",
" <td>2.370939</td>\n",
" </tr>\n",
" <tr>\n",
" <th>194</th>\n",
" <td>WILLOW SPRINGS CARE AND REHABILITATION</td>\n",
" <td>YAKIMA</td>\n",
" <td>0.227975</td>\n",
" <td>10.018229</td>\n",
" <td>14.660050</td>\n",
" <td>18.060675</td>\n",
" <td>17.395748</td>\n",
" <td>2.963673</td>\n",
" </tr>\n",
" <tr>\n",
" <th>195</th>\n",
" <td>WOODLAND CONVALESCENT CENTER</td>\n",
" <td>WOODLAND</td>\n",
" <td>0.188459</td>\n",
" <td>8.281736</td>\n",
" <td>12.118975</td>\n",
" <td>14.930158</td>\n",
" <td>14.380485</td>\n",
" <td>2.449970</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>196 rows × 8 columns</p>\n",
"</div>"
],
"text/plain": [
" Vendor Name City n_0-30 \\\n",
"0 ADVANCED POST ACUTE AUBURN 0.291808 \n",
"1 ALASKA GARDENS HEALTH AND REHABILITATION CENTER TACOMA 0.373879 \n",
"2 ALDERCREST HEALTH & REHABILITATION CENTER EDMONDS 0.389077 \n",
"3 ALDERWOOD MANOR SPOKANE 0.258372 \n",
".. ... ... ... \n",
"192 WHITMAN HEALTH AND REHABILITATION CENTER COLFAX 0.167182 \n",
"193 WILLAPA HARBOR HEALTH & REHAB RAYMOND 0.182380 \n",
"194 WILLOW SPRINGS CARE AND REHABILITATION YAKIMA 0.227975 \n",
"195 WOODLAND CONVALESCENT CENTER WOODLAND 0.188459 \n",
"\n",
" n_31-64 n_65-74 n_75-84 n_85-95 n_96+ \n",
"0 12.823333 18.764864 23.117664 22.266558 3.793502 \n",
"1 16.429895 24.042482 29.619507 28.529027 4.860424 \n",
"2 17.097777 25.019819 30.823552 29.688744 5.058002 \n",
"3 11.353992 16.614723 20.468765 19.715181 3.358830 \n",
".. ... ... ... ... ... \n",
"192 7.346701 10.750703 13.244495 12.756882 2.173360 \n",
"193 8.014583 11.728040 14.448540 13.916599 2.370939 \n",
"194 10.018229 14.660050 18.060675 17.395748 2.963673 \n",
"195 8.281736 12.118975 14.930158 14.380485 2.449970 \n",
"\n",
"[196 rows x 8 columns]"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# assume that proportion of patients in each age group follows proportion of beds\n",
"\n",
"df_beds['bed_frac'] = df_beds['Bed Count'] / df_beds['Bed Count'].sum()\n",
"\n",
"for age in age_frac.index:\n",
" df_beds[f'n_{age}'] = df_beds.bed_frac * n_by_age[age]\n",
" \n",
"df_beds.filter(['Vendor Name', 'City'] + [f'n_{age}' for age in age_frac.index])"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"# clean up the data a little --- lower-case pythonic column names, and no shouting\n",
"\n",
"df_beds['facility'] = df_beds['Vendor Name'].str.lower()\n",
"df_beds['location'] = df_beds['City'].str.lower()"
]
},
{
"cell_type": "code",
"execution_count": 12,
"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>facility</th>\n",
" <th>location</th>\n",
" <th>n_0-30</th>\n",
" <th>n_31-64</th>\n",
" <th>n_65-74</th>\n",
" <th>n_75-84</th>\n",
" <th>n_85-95</th>\n",
" <th>n_96+</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>advanced post acute</td>\n",
" <td>auburn</td>\n",
" <td>0.291808</td>\n",
" <td>12.823333</td>\n",
" <td>18.764864</td>\n",
" <td>23.117664</td>\n",
" <td>22.266558</td>\n",
" <td>3.793502</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>alaska gardens health and rehabilitation center</td>\n",
" <td>tacoma</td>\n",
" <td>0.373879</td>\n",
" <td>16.429895</td>\n",
" <td>24.042482</td>\n",
" <td>29.619507</td>\n",
" <td>28.529027</td>\n",
" <td>4.860424</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>aldercrest health &amp; rehabilitation center</td>\n",
" <td>edmonds</td>\n",
" <td>0.389077</td>\n",
" <td>17.097777</td>\n",
" <td>25.019819</td>\n",
" <td>30.823552</td>\n",
" <td>29.688744</td>\n",
" <td>5.058002</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>alderwood manor</td>\n",
" <td>spokane</td>\n",
" <td>0.258372</td>\n",
" <td>11.353992</td>\n",
" <td>16.614723</td>\n",
" <td>20.468765</td>\n",
" <td>19.715181</td>\n",
" <td>3.358830</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",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>192</th>\n",
" <td>whitman health and rehabilitation center</td>\n",
" <td>colfax</td>\n",
" <td>0.167182</td>\n",
" <td>7.346701</td>\n",
" <td>10.750703</td>\n",
" <td>13.244495</td>\n",
" <td>12.756882</td>\n",
" <td>2.173360</td>\n",
" </tr>\n",
" <tr>\n",
" <th>193</th>\n",
" <td>willapa harbor health &amp; rehab</td>\n",
" <td>raymond</td>\n",
" <td>0.182380</td>\n",
" <td>8.014583</td>\n",
" <td>11.728040</td>\n",
" <td>14.448540</td>\n",
" <td>13.916599</td>\n",
" <td>2.370939</td>\n",
" </tr>\n",
" <tr>\n",
" <th>194</th>\n",
" <td>willow springs care and rehabilitation</td>\n",
" <td>yakima</td>\n",
" <td>0.227975</td>\n",
" <td>10.018229</td>\n",
" <td>14.660050</td>\n",
" <td>18.060675</td>\n",
" <td>17.395748</td>\n",
" <td>2.963673</td>\n",
" </tr>\n",
" <tr>\n",
" <th>195</th>\n",
" <td>woodland convalescent center</td>\n",
" <td>woodland</td>\n",
" <td>0.188459</td>\n",
" <td>8.281736</td>\n",
" <td>12.118975</td>\n",
" <td>14.930158</td>\n",
" <td>14.380485</td>\n",
" <td>2.449970</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>196 rows × 8 columns</p>\n",
"</div>"
],
"text/plain": [
" facility location n_0-30 \\\n",
"0 advanced post acute auburn 0.291808 \n",
"1 alaska gardens health and rehabilitation center tacoma 0.373879 \n",
"2 aldercrest health & rehabilitation center edmonds 0.389077 \n",
"3 alderwood manor spokane 0.258372 \n",
".. ... ... ... \n",
"192 whitman health and rehabilitation center colfax 0.167182 \n",
"193 willapa harbor health & rehab raymond 0.182380 \n",
"194 willow springs care and rehabilitation yakima 0.227975 \n",
"195 woodland convalescent center woodland 0.188459 \n",
"\n",
" n_31-64 n_65-74 n_75-84 n_85-95 n_96+ \n",
"0 12.823333 18.764864 23.117664 22.266558 3.793502 \n",
"1 16.429895 24.042482 29.619507 28.529027 4.860424 \n",
"2 17.097777 25.019819 30.823552 29.688744 5.058002 \n",
"3 11.353992 16.614723 20.468765 19.715181 3.358830 \n",
".. ... ... ... ... ... \n",
"192 7.346701 10.750703 13.244495 12.756882 2.173360 \n",
"193 8.014583 11.728040 14.448540 13.916599 2.370939 \n",
"194 10.018229 14.660050 18.060675 17.395748 2.963673 \n",
"195 8.281736 12.118975 14.930158 14.380485 2.449970 \n",
"\n",
"[196 rows x 8 columns]"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"t = df_beds.filter(['facility', 'location'] + [f'n_{age}' for age in age_frac.index])\n",
"t"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"assert np.allclose(t.filter([f'n_{age}' for age in age_frac.index]).sum().sum(), n_total)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"t.to_csv('/home/j/Project/simulation_science/covid/data/age_specific_nursing_home_pop.csv', index=False)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "dismod_mr",
"language": "python",
"name": "dismod_mr"
},
"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.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment