Open MaxGhenis opened 2 years ago
This works:
from openfisca_us import Microsimulation sim = Microsimulation() sim.df(["state_code", "snap_gross_income_fpg_ratio"])
but this doesn't:
sim.df(["snap_gross_income_fpg_ratio", "state_code"])
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) [<ipython-input-11-856cb2e0dc06>](https://localhost:8080/#) in <module>() ----> 1 df = sim.df(["snap_gross_income_fpg_ratio", "state_code"]) 2 ca_below_fpl = df[(df.snap_gross_income_fpg_ratio < 1) & (df.state_code == "CA")] 3 ca_below_fpl 3 frames [/usr/local/lib/python3.7/dist-packages/openfisca_tools/microsimulation.py](https://localhost:8080/#) in map_to(self, arr, entity, target_entity, how) 216 return entity_pop.project(arr) 217 if how == "mean": --> 218 return entity_pop.project(arr / entity_pop.nb_persons()) 219 elif entity == target_entity: 220 return arr TypeError: ufunc 'true_divide' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
state_code is a household-level string, snap_gross_income_fpg_ratio is a spmu-level float.
state_code
snap_gross_income_fpg_ratio
OK, so this is because the spm_unit -> household mapping works for the string type, but not the other way around. Will need some logic added to the map_to function.
map_to
This works:
but this doesn't:
state_code
is a household-level string,snap_gross_income_fpg_ratio
is a spmu-level float.