Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

`Microsimulation.df` throws `TypeError` with some sequences of variables

Aperta
#53 1 commento 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python
Ambito
data

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

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.

Lingua principale
Python
Stelle
1
Fork
1
Merge medio
11h 16m
PR unite (30g)
2

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di PolicyEngine/openfisca-tools

Tutte le issue di PolicyEngine/openfisca-tools

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.