Commit graph

259 commits

Author SHA1 Message Date
Shelby Switzer
819f3ff478
Update etl constants to use score field_names and put strings around tract IDs in downloadable CSV (#985)
* Update etl constants to use score field_names

Put strings around tract IDs in downloadable CSV

No need to modify the xls file creation because the string type is
preserved and interpreted correctly in Excel already.

One note is that this does cause the ID in the CSV to be have quotes
around it, which might be annoying. Maybe we don't want this behavior?

* Update based on PR feedback and lint needs

* Change field we're using in downloadable

This reverts the downloadable csv field list to use
MEDIAN_INCOME_AS_PERCENT_OF_STATE_FIELD instead of
MEDIAN_INCOME_AS_PERCENT_OF_AMI_FIELD in order to get the test to pass.
The point of this PR is a refactor (and a small change to the CSV
quotations), not to change the output. That will be a different PR
later.

Co-authored-by: Shelby Switzer <shelby.switzer@cms.hhs.gov>
2021-12-06 13:17:17 -05:00
Jorge Escobar
bbc4a4dec0
Fix bug that dropped rows from island territories (#981)
Co-authored-by: lucasmbrown-usds <lucas.m.brown@omb.eop.gov>
2021-12-05 20:00:53 -05:00
Saran Ahluwalia
07ee4165b4
New Create indicators for all thresholds exceeded by a community in Definition L (#980)
* added fieldnames

* todo pollution, water, health & workforce

* workforce

* work in progress

* add utility function to replace duplicate summation logic

* move fpl series into add columns - run black .

* added revisions - still a wip

* added fieldnames

* todo pollution, water, health & workforce

* workforce

* work in progress

* add utility function to replace duplicate summation logic

* move fpl series into add columns - run black .

* added revisions - still a wip

* revise workforce and water

* revise housing and add incremental counter for workforce

* last PR nit

* revise workforce

* more PR feedback in score l

* more PR feedback in score l

* more PR feedback in score l

* addd FPL_SERIES and update references in score 1

* fix bugs

* reparameterize function

* final revisions in fieldnames

* make computations all consistent so we assing with FPL_200_SERIES

* fieldnames refactor after clarification and PR review

* finalize

* finalize with no typos

* fix length

* added median income var

* swap thresholds

* remove iteration

* remove stray '

* address flake 8

* added f string formatting and fixed typos

* added f string formatting and fixed typos

* move up

* remove dupes

* reformat

* fix bugs

* fix bugs

* initialize

Co-authored-by: Saran Ahluwalia <sarahluw@cisco.com>
2021-12-05 19:51:19 -05:00
Lucas Merrill Brown
d705a8244c
adding demographics information to ETL source data (#982) 2021-12-05 17:56:45 -05:00
Saran Ahluwalia
610343a1e3
DoE fix to address #975 (#979)
* Fixed input field name

Co-authored-by: Saran Ahluwalia <sarahluw@cisco.com>
2021-12-05 08:26:39 -05:00
Saran Ahluwalia
19efdfeb4a
DoE LEAD References Need to be Updated (#976)
* replace temporary fieldnames that are not found and indexed

* fixed field names

* PR review

* PR review - revert

Co-authored-by: Saran Ahluwalia <sarahluw@cisco.com>
2021-12-04 12:38:50 -05:00
Lucas Merrill Brown
c5dff6e5f7
Issue 242: Add HOLC Grades to data inputs (#978)
* Add mapping inequality data to data inputs

* Add mapping inequality data to comparison tool
2021-12-04 12:23:01 -05:00
Lucas Merrill Brown
1d101c93d2
Issue 844: Add island areas to Definition L (#957)
This ended up being a pretty large task. Here's what this PR does:

1. Pulls in Vincent's data from island areas into the score ETL. This is from the 2010 decennial census, the last census of any kind in the island areas.
2. Grabs a few new fields from 2010 island areas decennial census.
3. Calculates area median income for island areas.
4. Stops using EJSCREEN as the source of our high school education data and directly pulls that from census (this was related to this project so I went ahead and fixed it).
5. Grabs a bunch of data from the 2010 ACS in the states/Puerto Rico/DC, so that we can create percentiles comparing apples-to-apples (ish) from 2010 island areas decennial census data to 2010 ACS data. This required creating a new class because all the ACS fields are different between 2010 and 2019, so it wasn't as simple as looping over a year parameter.
6. Creates a combined population field of island areas and mainland so we can use those stats in our comparison tool, and updates the comparison tool accordingly.
2021-12-03 15:46:10 -05:00
Saran Ahluwalia
8cb9d197df
updated doe enerygy link and changed fieldnames - removed computation step as BURDEN is already ratio (#963)
Co-authored-by: Saran Ahluwalia <sarahluw@cisco.com>
2021-12-03 13:33:19 -05:00
Saran Ahluwalia
8cb1070d1e
Integrate proximity to waste sites into pollution factors (#959)
* add tsdf proximity into predicate to determine thresholds

* strict inequality --> inclusive

Co-authored-by: Saran Ahluwalia <sarahluw@cisco.com>
2021-12-03 12:43:48 -05:00
Saran Ahluwalia
fdba1eb171
Revisions to FEMA measure and new link for FEMA data (#952)
* per tract collect all diaster total annual expected loss - numerator

* add updated numerators

* EALP columns are missing on tox check - this will ensure only EALP columns that exist are subet on

* EALB columns are missing on tox check - this will ensure only EALP columns that exist are subet on

* reverted to incorporate megatracts

* updated unit tests

* fix tests

* add transform

* remove print statement

* input reflects input from FEMA risks for tracts

* revise tests and update fixtures - clean up tests and main transform function

* added more records

* remove references to Blocks in keyword args in tests

* linting

* addressed latest PR feedback

* remove imports and update arguments to be compatible for 1.1.0

* remove block reference in test

* change precision to 10 digits - refactor tests to accomdate this

Co-authored-by: Saran Ahluwalia <sarahluw@cisco.com>
2021-12-03 12:42:07 -05:00
Vincent La
84874ee4a5
[ISS-751] Updating comments for geocorr ETL (#913) 2021-12-03 10:10:05 -05:00
Saran Ahluwalia
0873d79254
change threshold for workforce factor (#950)
Co-authored-by: Saran Ahluwalia <sarahluw@cisco.com>
2021-12-02 16:43:22 -05:00
Lucas Merrill Brown
5c65eed28f
Issue 838: Update comparison tool to use tracts (#934)
* Updating comparison tool to use tracts, and rely more heavily on `field_names`
2021-11-30 18:46:29 -05:00
Saran Ahluwalia
6d0cb29dcd
create new copy and remove chained assignment (#939)
Co-authored-by: Saran Ahluwalia <sarahluw@cisco.com>
2021-11-30 14:20:29 -05:00
Lucas Merrill Brown
d2352c6217 Fix too many tracts in join error in ACS (#933) 2021-11-30 13:49:21 -05:00
Jorge Escobar
078bf6d8b6 Tract Work Score Geo (#926) 2021-11-30 13:49:21 -05:00
Jorge Escobar
cc7bf0d73d County mapping to Tracts (#923)
* County mapping to Tracts

* passing tests

* last traces of cbg
2021-11-30 13:49:21 -05:00
Lucas Merrill Brown
a4108d24c0 Issue 919: Fix too many tracts issue (#922)
* Some cleanup, adding error warning to merge function

* Error handling around tract merge
2021-11-30 13:49:20 -05:00
Jorge Escobar
16eb29e429 EJScreen Tracts (#918)
* EJScreen Tracts

* EJScreen Tracts
2021-11-30 13:49:20 -05:00
Jorge Escobar
f915e20e91 Esfoobar usds/835 census tracts geojson (#916)
* Census Tracts instead of CBGs

* typo
2021-11-30 13:49:20 -05:00
Shelby Switzer
617f41526f Update Census AMI to ETL into tracts, not CBGs (#900)
* Update Census AMI to ETL into tracts, not CBGs

Co-authored-by: Shelby Switzer <shelby.switzer@cms.hhs.gov>
Co-authored-by: lucasmbrown-usds <lucas.m.brown@omb.eop.gov>
2021-11-30 13:49:20 -05:00
Lucas Merrill Brown
537844236a Update FEMA data to be tracts, not block groups (#906) 2021-11-30 13:49:20 -05:00
Shelby Switzer
893758f1d4 Use tract instead of block group when calling census API (#901)
* Use tract instead of block group when calling census API

* fixing merge conflicts

Co-authored-by: Shelby Switzer <shelby.switzer@cms.hhs.gov>
Co-authored-by: lucasmbrown-usds <lucas.m.brown@omb.eop.gov>
2021-11-30 13:49:20 -05:00
Shelby Switzer
0c8b32e679 Move Housing and Transportation Index to tracts (#903)
Update data download URL to use tract as focus, use tract field name,
and move this dataset to the tracts df list in etl_score.

Co-authored-by: Shelby Switzer <shelby.switzer@cms.hhs.gov>
2021-11-30 13:49:20 -05:00
Lucas Merrill Brown
776a52595f Switching island territories data to tracts (#879) 2021-11-30 13:49:20 -05:00
Saran Ahluwalia
b0c176daee
Remove inplace argument to prevent SettingWithCopyError (#899)
* removed inplace argument to prevent copies of dataframe to be set and chained assignment to propogate and raise exception

* removed inplace argument to prevent copies of dataframe to be set and chained assignment to propogate and raise exception

* remove superfluous pandas options that affects flake results

* remove (again) the same chained assignment from previous merge

Co-authored-by: Saran Ahluwalia <sarahluw@cisco.com>
2021-11-29 13:27:23 -05:00
Saran Ahluwalia
ec8f3543e5
Remove Index related to FEMA (#917)
Co-authored-by: Saran Ahluwalia <sarahluw@cisco.com>
2021-11-24 16:50:09 -05:00
Lucas Merrill Brown
474d010bf4
Quick fix on island territories directory name (#877) 2021-11-16 14:31:11 -05:00
Jorge Escobar
0a21fc6b12
Add territory boundary data (#885)
* Add territory boundary data

* housing and transp

* lint

* lint

* lint
2021-11-16 10:05:09 -05:00
Lucas Merrill Brown
e8d64df510
Fixing missing FEMA fields (#892) 2021-11-15 11:06:44 -05:00
Lucas Merrill Brown
21834b4a91
Issue 883: Update FEMA risk index measure (#884)
* ETL updated

* Adding three fields to score
2021-11-13 11:32:15 -05:00
Lucas Merrill Brown
05ebf9b48c
Add median house value to Definition L (#882)
* Added house value to ETL

* Adding house value to score formula and comp tool
2021-11-13 10:29:23 -05:00
Vincent La
b0dbc90064
[ISS-723] Load Census Data for 4 Territories (#816)
* Adding census decennial data for island territories
2021-11-09 16:32:46 -05:00
Jorge Escobar
053dde0d40
Display score L on map (#849)
* updates to first docker run

* tile constants

* frontend changes

* updating pickles instructions

* pickles
2021-11-05 16:26:14 -04:00
Lucas Merrill Brown
03e59f2abd
Definition L updates (#862)
* Changing FEMA risk measure 

* Adding "basic stats" feature to comparison tool 

* Tweaking Definition L
2021-11-05 15:43:52 -04:00
Shelby Switzer
a0bf186ee6
Add percentile column for L (#851)
* Add percentile column for L

* Use Definition instead of Score

Co-authored-by: Shelby Switzer <shelby.switzer@cms.hhs.gov>
2021-11-04 13:03:56 -04:00
Lucas Merrill Brown
8372b47d42
Various updates to Definition L (#850)
* removing percentiles as separate field names

* adding RMP
2021-11-04 12:17:45 -04:00
Lucas Merrill Brown
1d541be447
Add EJSCREEN Areas of Concern (#843)
* Adding ej screen areas of concern

* Uses it where user has local files, but not otherwise

Co-authored-by: VincentLaUSDS <vincent.la@omb.eop.gov>
2021-11-02 15:38:42 -04:00
Shelby Switzer
7bd1a9e59e
Big ole score refactor (#815)
* WIP

* Create ScoreCalculator

This calculates all the factors for score L for now (with placeholder
formulae because this is a WIP). I think ideallly we'll want to
refactor all the score code to be extracted into this or  similar
classes.

* Add factor logic for score L

Updated factor logic to match score L factors methodology.
Still need to get the Score L field itself working.

Cleanup needed: Pull field names into constants file, extract all score
calculation into score calculator

* Update thresholds and get score L calc working

* Update header name for consistency and update comparison tool

* Initial move of score to score calculator

* WIP big refactor

* Continued WIP on score refactor

* WIP score refactor

* Get to a working score-run

* Refactor to pass df to score init

This makes it easier to pass df around within a class with multiple
methods that require df.

* Updates from Black

* Updates from linting

* Use named imports instead of wildcard; log more

* Additional refactors

* move more field names to field_names constants file
* import constants without a relative path (would break docker)
* run linting
* raise error if add_columns is not implemented in a child class

* Refactor dict to namedtuple in score c

* Update L to use all percentile field

* change high school ed field in L back

Co-authored-by: Shelby Switzer <shelby.switzer@cms.hhs.gov>
2021-11-02 14:12:53 -04:00
Jorge Escobar
1b17af84c8
Combine + Tilefy (#806)
* init

* score-post

* added score csv s3 download; remore poetry cmds from readme

* working census tile fetch

* PR review

* Github Actions Work
2021-11-01 18:05:05 -04:00
Shelby Switzer
7b87e0ec99
Add Score L (#812)
* Create ScoreCalculator

This calculates all the factors for score L for now (with placeholder
formulae because this is a WIP). I think ideallly we'll want to
refactor all the score code to be extracted into this or  similar
classes.

* Add factor logic for score L

Updated factor logic to match score L factors methodology.
Still need to get the Score L field itself working.

Cleanup needed: Pull field names into constants file, extract all score
calculation into score calculator

Co-authored-by: Shelby Switzer <shelby.switzer@cms.hhs.gov>
Co-authored-by: lucasmbrown-usds <lucas.m.brown@omb.eop.gov>
2021-10-28 16:07:41 -04:00
Jorge Escobar
a94b8e2761 final census GHA 2021-10-14 13:50:56 -04:00
Jorge Escobar
8ddfc6b305
Update application.py 2021-10-14 13:31:37 -04:00
Jorge Escobar
3b04356fb3
Data sources from S3 (#769)
* Started 535

* Data sources from S3

* lint

* renove breakpoints

* PR comments

* lint

* census data completed

* lint

* renaming data source
2021-10-13 16:00:33 -04:00
Billy Daly
d1273b63c5
Add ETL Contract Checks (#619)
* Adds dev dependencies to requirements.txt and re-runs black on codebase

* Adds test and code for national risk index etl, still in progress

* Removes test_data from .gitignore

* Adds test data to nation_risk_index tests

* Creates tests and ETL class for NRI data

* Adds tests for load() and transform() methods of NationalRiskIndexETL

* Updates README.md with info about the NRI dataset

* Adds to dos

* Moves tests and test data into a tests/ dir in national_risk_index

* Moves tmp_dir for tests into data/tmp/tests/

* Promotes fixtures to conftest and relocates national_risk_index tests:
The relocation of national_risk_index tests is necessary because tests 
can only use fixtures specified in conftests within the same package

* Fixes issue with df.equals() in test_transform()

* Files reformatted by black

* Commit changes to other files after re-running black

* Fixes unused import that caused lint checks to fail

* Moves tests/ directory to app root for data_pipeline

* Adds new methods to ExtractTransformLoad base class:
- __init__() Initializes class attributes
- _get_census_fips_codes() Loads a dataframe with the fips codes for 
census block group and tract
- validate_init() Checks that the class was initialized correctly
- validate_output() Checks that the output was loaded correctly

* Adds test for ExtractTransformLoad.__init__() and base.py

* Fixes failing flake8 test

* Changes geo_col to geoid_col and changes is_dataset to is_census in yaml

* Adds test for validate_output()

* Adds remaining tests

* Removes is_dataset from init method

* Makes CENSUS_CSV a class attribute instead of a class global:
This ensures that CENSUS_CSV is only set when the ETL class is for a 
non-census dataset and removes the need to overwrite the value in 
mock_etl fixture

* Re-formats files with black and fixes broken tox tests
2021-10-13 15:54:15 -04:00
Shelby Switzer
d8c73e6a02
Change downloadable file names (#708)
* Change downloadable file names

* Remove constants because we're dynamically creating these
* Update to "communities" for the descriptor word based on team convo
* Add timestamp in 2020-09-20-0930 format because I personally think
this is the best ^.^

* Add a CLI command to run ETL Score Post so that we don't have to
  run the score generation just to get new downloadable files.
* Also make sure the old downloadable files are cleaned up on the
  run of this command.

* Remove unused library, thanks pylint!

Co-authored-by: Shelby Switzer <shelby.switzer@cms.hhs.gov>
2021-10-01 15:04:37 -04:00
Jorge Escobar
2f8f2240b4
added new PDF file (#745) 2021-09-23 13:34:50 -04:00
Lucas Merrill Brown
b1a4d26be8
Adding persistent poverty tracts (#738)
* persistent poverty working

* fixing left-padding

* running black and adding persistent poverty to comp tool

* fixing bug

* running black and fixing linter

* fixing linter

* fixing linter error
2021-09-22 17:57:08 -04:00
Shelby Switzer
d3a18352fc
Add pytest to tox run in CI/CD (#713)
* Add pytest to tox run in CI/CD

* Try fixing tox dependencies for pytest

* update poetry to get ci/cd passing

* Run poetry export with --dev flag to include dev dependencies such as pytest

* WIP updating test fixtures to include PDF

* Remove dev dependencies from reqs and add pytest to envlist to make build faster

* passing score_post tests

* Add pytest tox (#729)

* Fix failing pytest

* Fixes failing tox tests and updates requirements.txt to include dev deps

* pickle protocol 4

Co-authored-by: Shelby Switzer <shelby.switzer@cms.hhs.gov>
Co-authored-by: Jorge Escobar <jorge.e.escobar@omb.eop.gov>
Co-authored-by: Billy Daly <williamdaly422@gmail.com>
Co-authored-by: Jorge Escobar <83969469+esfoobar-usds@users.noreply.github.com>
2021-09-22 13:47:37 -04:00