Datawheel / canon-stats

Reusable statistical and complexity calculations using NodeJS and Express
1 stars 1 forks source link

modifies proximity endpoint #20

Closed ffigueroal closed 4 years ago

ffigueroal commented 4 years ago

Allows users to calculates proximities values with new endpoints params:

filter_<depth>: returns only products related with selected Source product (e.g filter_HS6=1020710). Works for Section, HS2, HS4 and HS6 levels. filter_Country: returns only products related with each Source product that has RCA > 1 in the selected Country (e.g. filter_Country=aschn) proximity_min: returns proximities values above the minimun level defined (e.g. proximity_min=0.5)

Endpoint example: /api/stats/proximity?cube=trade_i_baci_a_92&Year=2018&measures=Trade+Value&drilldowns=Exporter+Country,HS2&rca=Exporter+Country,HS2,Trade+Value&alias=Country,HS2&parents=true&filter_Country=aschn&filter_HS2=105&proximity_min=0.1

image

cnavarreteliz commented 4 years ago

And additional comment from my side: Not always is filter_Country, sometimes it can be filter_Subnat Geography or another geo level.

cnavarreteliz commented 4 years ago

@ffigueroal do you have time this week for handling this PR?

ffigueroal commented 4 years ago

Good job!

  • Can you include RCA when the user uses filter_{dd1}?

@cnavarreteliz did you mean something like this? image I'm adding the rca value used at the first step at the end of the function:

output = output.merge(temp, left_on="{} Target".format(dd2_id), right_on=dd2_id)