`Microsimulation.df` throws `TypeError` with some sequences of variables
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
Start in openfisca_tools/microsimulation.py at map_to, using the two variable-order examples in the issue to reproduce the TypeError. Confirm that both sequences return a dataframe successfully and add regression coverage for the household string and spmu float combination.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Python
- Stars
- 1
- Forks
- 1
- Avg merge
- 11h 16m
- Merged PRs (30d)
- 2
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PolicyEngine/openfisca-tools
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 25/100
PolicyEngine/openfisca-tools#65 · 4 comments ·
All issues in PolicyEngine/openfisca-tools
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
UKGovernmentBEIS/control-arena#917 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
debpalash/VoiceStudio#2937 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
aws-samples/sample-per-model-bedrock#261 ·
Maintainers usually reply within 1 day