vSigns


NamevSigns JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/bnia/VitalSigns/tree/main/
SummaryPython Scripts for BNIA-JFIs Vital Signs Data
upload_time2022-12-16 16:09:37
maintainer
docs_urlNone
authorGerman Paredes
requires_python>=3.6
licenseApache Software License 2.0
keywords community data
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Vital Signs
> Scripts to create our annual, publicly-available, community-focused datasets; for Baltimore City.


<img src="https://raw.githubusercontent.com/bniajfi/vSigns/main/https://raw.githubusercontent.com/bniajfi/bniajfi/main/bnia_logo_new.png" height="160px" width="auto" style="max-width: autopx">

<h2>Hi! We are <a href="https://bniajfi.org/">BNIA-JFI</a>.</h2>

This package was made to create Vital Signs data.

Check our [Github](https://github.com/bniajfi) page for more information and tools.

__About__
- Functions built and used by BNIA for annual Vital Signs data release.
- Made to be shared via IPYNB/ Google Colab notebooks. 
- Data may be private and is sometimes public.
- [PyPi](https://pypi.org/project/BNIAJFI-VitalSigns/) libraries created from the notebooks.

__Included__ (but not limited to)
- CloseCrawl - Pull MD Courts data.
- TidyAddr - Expertly clean addresses in Baltimore (and beyond). Works Seamlessly with Closecrawl. 
- Download ACS - ACS Tutorial. Gives a function and also teaches you how to pull any data for any geography using this API (can aggregate tracts on along a crosswalk).
- Create ACS Statistics - Create pre-made statistics from ACS data. Builds off the ACS Downloader
- VS Indicators - Create other (non ACS) Vital Signs statistics using these pre-made functions.
- convertvssheetforwpupload - For internal developer use when publishing at BNIA

VitalSigns uses functions found in our Dataplay Module and vice-versa.

[![Binder](https://pete88b.github.io/fastpages/assets/badges/colab.svg)](https://colab.research.google.com/github/bnia/VitalSigns/blob/main/notebooks/index.ipynb)
[![Binder](https://pete88b.github.io/fastpages/assets/badges/github.svg)](https://github.com/bnia/VitalSigns/tree/main/notebooks/index.ipynb)
[![Open Source Love svg3](https://badges.frapsoft.com/os/v3/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badges/)

[![NPM License](https://img.shields.io/npm/l/all-contributors.svg?style=flat)](https://github.com/bnia/VitalSigns/blob/main/LICENSE)
[![Active](http://img.shields.io/badge/Status-Active-green.svg)](https://bnia.github.io) 
[![Python Versions](https://img.shields.io/pypi/pyversions/VitalSigns.svg)](https://pypi.python.org/pypi/VitalSigns/)
[![GitHub last commit](https://img.shields.io/github/last-commit/bnia/VitalSigns.svg?style=flat)]()  

[![GitHub stars](https://img.shields.io/github/stars/bnia/VitalSigns.svg?style=social&label=Star)](https://github.com/bnia/VitalSigns) 
[![GitHub watchers](https://img.shields.io/github/watchers/bnia/VitalSigns.svg?style=social&label=Watch)](https://github.com/bnia/VitalSigns) 
[![GitHub forks](https://img.shields.io/github/forks/bnia/VitalSigns.svg?style=social&label=Fork)](https://github.com/bnia/VitalSigns) 
[![GitHub followers](https://img.shields.io/github/followers/bnia.svg?style=social&label=Follow)](https://github.com/bnia/VitalSigns) 

[![Tweet](https://img.shields.io/twitter/url/https/github.com/bnia/VitalSigns.svg?style=social)](https://twitter.com/intent/tweet?text=Check%20out%20this%20%E2%9C%A8%20colab%20by%20@bniajfi%20https://github.com/bnia/VitalSigns%20%F0%9F%A4%97) 
[![Twitter Follow](https://img.shields.io/twitter/follow/bniajfi.svg?style=social)](https://twitter.com/bniajfi)

## Usage Instructions

### Install the Package

The code is on <a href="https://pypi.org/project/VitalSigns2022TEST/">PyPI</a> so you can install the scripts as a python library using the command:
```
!pip install BNIAJFI-VitalSigns dataplay geopandas
```

### Import Modules

1) Import the installed module into your code:
``` 
from VitalSigns.acsDownload import retrieve_acs_data
```

2) use it
```
retrieve_acs_data(state, county, tract, tableId, year)
```

# Getting Help

You can get information on the package by using the help command.

Here we look at the package's modules:
```
import VitalSigns
help(VitalSigns)
```

Lets take a look at what functions the geoms module provides:
```
import VitalSigns.acsDownload
help(VitalSigns.acsDownload)
```

And here we can look at an individual function and what it expects:
```
import VitalSigns.acsDownload
help(VitalSigns.acsDownload.retrieve_acs_data)
```

## Example #1 
Follow this process for all VitalSigns scripts. The 'racdiv' script requires one more step, and is shown in example #2

### ACS Download

Install the package.
```
!pip install BNIAJFI-VitalSigns dataplay geopandas
```

Import your modules.
```
from VitalSigns.acsDownload import retrieve_acs_data
```

Read in some data.
```
#Define our download parameters (tract, county, state, tableId, state, and year)
#Our download function will use Baltimore City's tract, county and state as internal parameters
#Changing these values using different geographic reference codes will change those parameters

tract = '*'
county = '510'
state = '24'

tableId = 'B01001'
year = '19'
```

And download the Baltimore City ACS data using the imported VitalSigns library.
```
df = retrieve_acs_data(state, county, tract, tableId, year)
df.head(2)
```

Save the ACS data (Use this method ONLY if you are working in Google Colab. Otherwise, you can save the data however you prefer)
```
from google.colab import files
df.to_csv('YourFileName.csv') 
files.download('YourFileName.csv')
```

### ACS Calculations and Indicators

Now that we have the ACS data, we can use any of the scripts in the VitalSigns library to create the Baltimore City indicators.

These scripts will download and clean ACS data for Baltimore and then construct indicators from the data.

A list of all the tables used and their respective indicator scripts can be found <a href="https://github.com/BNIA/VitalSigns/blob/main/ACS_Tables_and_Scripts.csv/">Here</a>

First, import the script(s)  you would like to use for the ACS data chosen.
```
#Script to create the Percent of Population Under 5 Years old indicator.
from VitalSigns.create import createAcsIndicator, age5 
```

Once the script has been imported, we can now create the Baltimore City indicators.
```
mergeUrl = 'https://raw.githubusercontent.com/BNIA/VitalSigns/main/CSA_2010_and_2020.csv'
merge_left_col = 'tract'
merge_right_col= 'TRACTCE' 
merge_how = 'outer'

groupBy = 'CSA2010'     #For the 2020 CSAs use 'CSA2020', for 2010 CSAs use 'CSA2010'

method = age5
aggMethod = 'sum'
columnsToInclude = []


MyIndicator = createAcsIndicator(state, county, tract, year, tableId,
                    mergeUrl, merge_left_col, merge_right_col, merge_how, groupBy,
                    aggMethod, method, columnsToInclude, finalFileName=False)

MyIndicator.head(2)
```

Now we can save the Baltimore City indicators (Use this method ONLY if you are working in Google Colab. Otherwise, you can save the data however you prefer)
```
from google.colab import files
MyIndicator.to_csv('YourIndicatorFileName.csv') 
files.download('YourIndicatorFileName.csv')
```

## Example #2 (racdiv indicator)
The Racial Diversity Index (racdiv) indicator is the only script in our library that relies on two ACS tables. 
Due to this difference, this is the only script that will ask the user for an input while the script is running (the user needs to re-enter the year)

Lets follow the same process we did during example #1
### ACS Download

Install the package.
```
!pip install BNIAJFI-VitalSigns dataplay geopandas
```

Import your modules.
```
from VitalSigns.acsDownload import retrieve_acs_data
```

Read in some data.
```
tract = '*'
county = '510'
state = '24'

tableId = 'B02001'
year = '19' #This is the number that the user NEEDS to re-enter once the script asks for an input
```

And download the Baltimore City ACS data using the imported VitalSigns library.
```
df = retrieve_acs_data(state, county, tract, tableId, year)
df.head(2)
```

Save the ACS data (Use this method ONLY if you are working in Google Colab. Otherwise, you can save the data however you prefer)
```
from google.colab import files
df.to_csv('YourFileName.csv') 
files.download('YourFileName.csv')
```
### ACS Calculations and Indicators
To see the table IDs and their respective indicators again, click <a href="https://github.com/BNIA/VitalSigns/blob/main/ACS_Tables_and_Scripts.csv/">Here</a>

Import the racdiv script 
```
#Script to create the Racial Diversity Index indicator.
from VitalSigns.create import createAcsIndicator, racdiv 
```

Once the script has been imported, we can now create the Baltimore City indicators.
```
mergeUrl = 'https://raw.githubusercontent.com/BNIA/VitalSigns/main/CSA_2010_and_2020.csv'
merge_left_col = 'tract'
merge_right_col= 'TRACTCE' 
merge_how = 'outer'

groupBy = 'CSA2010'     #For the 2020 CSAs use 'CSA2020', for 2010 CSAs use 'CSA2010'

method = racdiv
aggMethod = 'sum'
columnsToInclude = []


MyIndicator = createAcsIndicator(state, county, tract, year, tableId,
                    mergeUrl, merge_left_col, merge_right_col, merge_how, groupBy,
                    aggMethod, method, columnsToInclude, finalFileName=False)

MyIndicator.head(2)
```

The cell below shows the output while the racdiv script is being run. As you can see on the last line, the script asks the user to re-enter their chosen year. After re-entering the year, the script will finish running, and the racdiv indicator table will be completed.
```
Table: B02001, Year: 19 imported.
Index(['TRACTCE', 'GEOID10', 'CSA2010', 'GEOID', 'CSA2020'], dtype='object')
Merge file imported
Both are now merged.
Aggregating...
Aggregated
Creating Indicator
Please enter your chosen year again (i.e., '17', '20'): 
```

Now we can save the Baltimore City indicators (Use this method ONLY if you are working in Google Colab. Otherwise, you can save the data however you prefer)
```
from google.colab import files
MyIndicator.to_csv('YourIndicatorFileName.csv') 
files.download('YourIndicatorFileName.csv')
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/bnia/VitalSigns/tree/main/",
    "name": "vSigns",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "Community Data",
    "author": "German Paredes",
    "author_email": "german10paredes@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/dc/50/4148c7b30db608d6a1fa89e5165d60072a3bfc03dbffe58f25a48e98ca06/vSigns-0.0.2.tar.gz",
    "platform": null,
    "description": "# Vital Signs\r\n> Scripts to create our annual, publicly-available, community-focused datasets; for Baltimore City.\r\n\r\n\r\n<img src=\"https://raw.githubusercontent.com/bniajfi/vSigns/main/https://raw.githubusercontent.com/bniajfi/bniajfi/main/bnia_logo_new.png\" height=\"160px\" width=\"auto\" style=\"max-width: autopx\">\r\n\r\n<h2>Hi! We are <a href=\"https://bniajfi.org/\">BNIA-JFI</a>.</h2>\r\n\r\nThis package was made to create Vital Signs data.\r\n\r\nCheck our [Github](https://github.com/bniajfi) page for more information and tools.\r\n\r\n__About__\r\n- Functions built and used by BNIA for annual Vital Signs data release.\r\n- Made to be shared via IPYNB/ Google Colab notebooks. \r\n- Data may be private and is sometimes public.\r\n- [PyPi](https://pypi.org/project/BNIAJFI-VitalSigns/) libraries created from the notebooks.\r\n\r\n__Included__ (but not limited to)\r\n- CloseCrawl - Pull MD Courts data.\r\n- TidyAddr - Expertly clean addresses in Baltimore (and beyond). Works Seamlessly with Closecrawl. \r\n- Download ACS - ACS Tutorial. Gives a function and also teaches you how to pull any data for any geography using this API (can aggregate tracts on along a crosswalk).\r\n- Create ACS Statistics - Create pre-made statistics from ACS data. Builds off the ACS Downloader\r\n- VS Indicators - Create other (non ACS) Vital Signs statistics using these pre-made functions.\r\n- convertvssheetforwpupload - For internal developer use when publishing at BNIA\r\n\r\nVitalSigns uses functions found in our Dataplay Module and vice-versa.\r\n\r\n[![Binder](https://pete88b.github.io/fastpages/assets/badges/colab.svg)](https://colab.research.google.com/github/bnia/VitalSigns/blob/main/notebooks/index.ipynb)\r\n[![Binder](https://pete88b.github.io/fastpages/assets/badges/github.svg)](https://github.com/bnia/VitalSigns/tree/main/notebooks/index.ipynb)\r\n[![Open Source Love svg3](https://badges.frapsoft.com/os/v3/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badges/)\r\n\r\n[![NPM License](https://img.shields.io/npm/l/all-contributors.svg?style=flat)](https://github.com/bnia/VitalSigns/blob/main/LICENSE)\r\n[![Active](http://img.shields.io/badge/Status-Active-green.svg)](https://bnia.github.io) \r\n[![Python Versions](https://img.shields.io/pypi/pyversions/VitalSigns.svg)](https://pypi.python.org/pypi/VitalSigns/)\r\n[![GitHub last commit](https://img.shields.io/github/last-commit/bnia/VitalSigns.svg?style=flat)]()  \r\n\r\n[![GitHub stars](https://img.shields.io/github/stars/bnia/VitalSigns.svg?style=social&label=Star)](https://github.com/bnia/VitalSigns) \r\n[![GitHub watchers](https://img.shields.io/github/watchers/bnia/VitalSigns.svg?style=social&label=Watch)](https://github.com/bnia/VitalSigns) \r\n[![GitHub forks](https://img.shields.io/github/forks/bnia/VitalSigns.svg?style=social&label=Fork)](https://github.com/bnia/VitalSigns) \r\n[![GitHub followers](https://img.shields.io/github/followers/bnia.svg?style=social&label=Follow)](https://github.com/bnia/VitalSigns) \r\n\r\n[![Tweet](https://img.shields.io/twitter/url/https/github.com/bnia/VitalSigns.svg?style=social)](https://twitter.com/intent/tweet?text=Check%20out%20this%20%E2%9C%A8%20colab%20by%20@bniajfi%20https://github.com/bnia/VitalSigns%20%F0%9F%A4%97) \r\n[![Twitter Follow](https://img.shields.io/twitter/follow/bniajfi.svg?style=social)](https://twitter.com/bniajfi)\r\n\r\n## Usage Instructions\r\n\r\n### Install the Package\r\n\r\nThe code is on <a href=\"https://pypi.org/project/VitalSigns2022TEST/\">PyPI</a> so you can install the scripts as a python library using the command:\r\n```\r\n!pip install BNIAJFI-VitalSigns dataplay geopandas\r\n```\r\n\r\n### Import Modules\r\n\r\n1) Import the installed module into your code:\r\n``` \r\nfrom VitalSigns.acsDownload import retrieve_acs_data\r\n```\r\n\r\n2) use it\r\n```\r\nretrieve_acs_data(state, county, tract, tableId, year)\r\n```\r\n\r\n# Getting Help\r\n\r\nYou can get information on the package by using the help command.\r\n\r\nHere we look at the package's modules:\r\n```\r\nimport VitalSigns\r\nhelp(VitalSigns)\r\n```\r\n\r\nLets take a look at what functions the geoms module provides:\r\n```\r\nimport VitalSigns.acsDownload\r\nhelp(VitalSigns.acsDownload)\r\n```\r\n\r\nAnd here we can look at an individual function and what it expects:\r\n```\r\nimport VitalSigns.acsDownload\r\nhelp(VitalSigns.acsDownload.retrieve_acs_data)\r\n```\r\n\r\n## Example #1 \r\nFollow this process for all VitalSigns scripts. The 'racdiv' script requires one more step, and is shown in example #2\r\n\r\n### ACS Download\r\n\r\nInstall the package.\r\n```\r\n!pip install BNIAJFI-VitalSigns dataplay geopandas\r\n```\r\n\r\nImport your modules.\r\n```\r\nfrom VitalSigns.acsDownload import retrieve_acs_data\r\n```\r\n\r\nRead in some data.\r\n```\r\n#Define our download parameters (tract, county, state, tableId, state, and year)\r\n#Our download function will use Baltimore City's tract, county and state as internal parameters\r\n#Changing these values using different geographic reference codes will change those parameters\r\n\r\ntract = '*'\r\ncounty = '510'\r\nstate = '24'\r\n\r\ntableId = 'B01001'\r\nyear = '19'\r\n```\r\n\r\nAnd download the Baltimore City ACS data using the imported VitalSigns library.\r\n```\r\ndf = retrieve_acs_data(state, county, tract, tableId, year)\r\ndf.head(2)\r\n```\r\n\r\nSave the ACS data (Use this method ONLY if you are working in Google Colab. Otherwise, you can save the data however you prefer)\r\n```\r\nfrom google.colab import files\r\ndf.to_csv('YourFileName.csv') \r\nfiles.download('YourFileName.csv')\r\n```\r\n\r\n### ACS Calculations and Indicators\r\n\r\nNow that we have the ACS data, we can use any of the scripts in the VitalSigns library to create the Baltimore City indicators.\r\n\r\nThese scripts will download and clean ACS data for Baltimore and then construct indicators from the data.\r\n\r\nA list of all the tables used and their respective indicator scripts can be found <a href=\"https://github.com/BNIA/VitalSigns/blob/main/ACS_Tables_and_Scripts.csv/\">Here</a>\r\n\r\nFirst, import the script(s)  you would like to use for the ACS data chosen.\r\n```\r\n#Script to create the Percent of Population Under 5 Years old indicator.\r\nfrom VitalSigns.create import createAcsIndicator, age5 \r\n```\r\n\r\nOnce the script has been imported, we can now create the Baltimore City indicators.\r\n```\r\nmergeUrl = 'https://raw.githubusercontent.com/BNIA/VitalSigns/main/CSA_2010_and_2020.csv'\r\nmerge_left_col = 'tract'\r\nmerge_right_col= 'TRACTCE' \r\nmerge_how = 'outer'\r\n\r\ngroupBy = 'CSA2010'     #For the 2020 CSAs use 'CSA2020', for 2010 CSAs use 'CSA2010'\r\n\r\nmethod = age5\r\naggMethod = 'sum'\r\ncolumnsToInclude = []\r\n\r\n\r\nMyIndicator = createAcsIndicator(state, county, tract, year, tableId,\r\n                    mergeUrl, merge_left_col, merge_right_col, merge_how, groupBy,\r\n                    aggMethod, method, columnsToInclude, finalFileName=False)\r\n\r\nMyIndicator.head(2)\r\n```\r\n\r\nNow we can save the Baltimore City indicators (Use this method ONLY if you are working in Google Colab. Otherwise, you can save the data however you prefer)\r\n```\r\nfrom google.colab import files\r\nMyIndicator.to_csv('YourIndicatorFileName.csv') \r\nfiles.download('YourIndicatorFileName.csv')\r\n```\r\n\r\n## Example #2 (racdiv indicator)\r\nThe Racial Diversity Index (racdiv) indicator is the only script in our library that relies on two ACS tables. \r\nDue to this difference, this is the only script that will ask the user for an input while the script is running (the user needs to re-enter the year)\r\n\r\nLets follow the same process we did during example #1\r\n### ACS Download\r\n\r\nInstall the package.\r\n```\r\n!pip install BNIAJFI-VitalSigns dataplay geopandas\r\n```\r\n\r\nImport your modules.\r\n```\r\nfrom VitalSigns.acsDownload import retrieve_acs_data\r\n```\r\n\r\nRead in some data.\r\n```\r\ntract = '*'\r\ncounty = '510'\r\nstate = '24'\r\n\r\ntableId = 'B02001'\r\nyear = '19' #This is the number that the user NEEDS to re-enter once the script asks for an input\r\n```\r\n\r\nAnd download the Baltimore City ACS data using the imported VitalSigns library.\r\n```\r\ndf = retrieve_acs_data(state, county, tract, tableId, year)\r\ndf.head(2)\r\n```\r\n\r\nSave the ACS data (Use this method ONLY if you are working in Google Colab. Otherwise, you can save the data however you prefer)\r\n```\r\nfrom google.colab import files\r\ndf.to_csv('YourFileName.csv') \r\nfiles.download('YourFileName.csv')\r\n```\r\n### ACS Calculations and Indicators\r\nTo see the table IDs and their respective indicators again, click <a href=\"https://github.com/BNIA/VitalSigns/blob/main/ACS_Tables_and_Scripts.csv/\">Here</a>\r\n\r\nImport the racdiv script \r\n```\r\n#Script to create the Racial Diversity Index indicator.\r\nfrom VitalSigns.create import createAcsIndicator, racdiv \r\n```\r\n\r\nOnce the script has been imported, we can now create the Baltimore City indicators.\r\n```\r\nmergeUrl = 'https://raw.githubusercontent.com/BNIA/VitalSigns/main/CSA_2010_and_2020.csv'\r\nmerge_left_col = 'tract'\r\nmerge_right_col= 'TRACTCE' \r\nmerge_how = 'outer'\r\n\r\ngroupBy = 'CSA2010'     #For the 2020 CSAs use 'CSA2020', for 2010 CSAs use 'CSA2010'\r\n\r\nmethod = racdiv\r\naggMethod = 'sum'\r\ncolumnsToInclude = []\r\n\r\n\r\nMyIndicator = createAcsIndicator(state, county, tract, year, tableId,\r\n                    mergeUrl, merge_left_col, merge_right_col, merge_how, groupBy,\r\n                    aggMethod, method, columnsToInclude, finalFileName=False)\r\n\r\nMyIndicator.head(2)\r\n```\r\n\r\nThe cell below shows the output while the racdiv script is being run. As you can see on the last line, the script asks the user to re-enter their chosen year. After re-entering the year, the script will finish running, and the racdiv indicator table will be completed.\r\n```\r\nTable: B02001, Year: 19 imported.\r\nIndex(['TRACTCE', 'GEOID10', 'CSA2010', 'GEOID', 'CSA2020'], dtype='object')\r\nMerge file imported\r\nBoth are now merged.\r\nAggregating...\r\nAggregated\r\nCreating Indicator\r\nPlease enter your chosen year again (i.e., '17', '20'): \r\n```\r\n\r\nNow we can save the Baltimore City indicators (Use this method ONLY if you are working in Google Colab. Otherwise, you can save the data however you prefer)\r\n```\r\nfrom google.colab import files\r\nMyIndicator.to_csv('YourIndicatorFileName.csv') \r\nfiles.download('YourIndicatorFileName.csv')\r\n```\r\n",
    "bugtrack_url": null,
    "license": "Apache Software License 2.0",
    "summary": "Python Scripts for BNIA-JFIs Vital Signs Data",
    "version": "0.0.2",
    "split_keywords": [
        "community",
        "data"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "c147ecb1bef0cf9e790f709fcf5e931f",
                "sha256": "bda8f2eb58d6e75a7692090c4106f1e7392e895e37a41551f0493e5ab0a7295e"
            },
            "downloads": -1,
            "filename": "vSigns-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "c147ecb1bef0cf9e790f709fcf5e931f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 52967,
            "upload_time": "2022-12-16T16:09:37",
            "upload_time_iso_8601": "2022-12-16T16:09:37.665183Z",
            "url": "https://files.pythonhosted.org/packages/dc/50/4148c7b30db608d6a1fa89e5165d60072a3bfc03dbffe58f25a48e98ca06/vSigns-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-16 16:09:37",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "vsigns"
}
        
Elapsed time: 0.02433s