本文整理汇总了Python中openfisca_core.simulations.ScenarioSimulation.get_results_dataframe方法的典型用法代码示例。如果您正苦于以下问题:Python ScenarioSimulation.get_results_dataframe方法的具体用法?Python ScenarioSimulation.get_results_dataframe怎么用?Python ScenarioSimulation.get_results_dataframe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openfisca_core.simulations.ScenarioSimulation
的用法示例。
在下文中一共展示了ScenarioSimulation.get_results_dataframe方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: case_study
# 需要导入模块: from openfisca_core.simulations import ScenarioSimulation [as 别名]
# 或者: from openfisca_core.simulations.ScenarioSimulation import get_results_dataframe [as 别名]
def case_study(year = 2013):
# Creating a case_study household with one individual whose taxable income (salaire imposable, sali
# varies from 0 to maxrev = 100000 in nmen = 3 steps
simulation = ScenarioSimulation()
simulation.set_config(year = year,
reforme = True,
nmen = 11,
maxrev = 100000,
x_axis = 'sali')
print simulation.
# Adding a husband/wife on the same tax sheet (ie foyer, as conj) and of course same family (as part)
simulation.scenario.addIndiv(1, datetime(1975, 1, 1).date(), 'conj', 'part')
# Adding 3 kids on the same tax sheet and family
simulation.scenario.addIndiv(2, datetime(2001, 1, 1).date(), 'pac', 'enf')
simulation.scenario.addIndiv(3, datetime(2002, 1, 1).date(), 'pac', 'enf')
simulation.scenario.addIndiv(4, datetime(2003, 1, 1).date(), 'pac', 'enf')
# Set legislative parameters
simulation.set_param()
# Some prestation can be disabled (herethe aefa prestation) by uncommenting the following line
# simulation.disable_prestations( ['aefa'])
# Performing a parameterical reform (inspect openifsca-country.param.param.xml)
# Lower the part in the quotient familial for the third child from 1 to .5
print 'default value for P.ir.quotient_familial.enf2 : %s \n' % simulation.P.ir.quotient_familial.enf2
simulation.P.ir.quotient_familial.enf2 = 0
print 'reform value for P.ir.quotient_familial.enf2 : %s \n' % simulation.P.ir.quotient_familial.enf2
# Compute the pandas dataframe of the household case_study
df = simulation.get_results_dataframe(default = True)
print df.to_string()
# Save example to excel
# destination_dir = "c:/users/utilisateur/documents/"
# fname = "Example_%s.%s" %(str(yr), "xls")
# df.to_excel(destination_dir = "c:/users/utilisateur/documents/" + fname)
df_reform = simulation.get_results_dataframe()
print df_reform.to_string()
# Many other variables are accessible
# Input variables
print 'list of input variables : %s \n' % simulation.input_var_list
# Getting the value of some input variables
print simulation.input_table.table['so']
# Output variables
print 'list of output variables : %s \n' % simulation.output_var_list
print simulation.output_table.table['ir_plaf_qf']
print simulation.output_table_default.table['ir_plaf_qf']
示例2: test_case
# 需要导入模块: from openfisca_core.simulations import ScenarioSimulation [as 别名]
# 或者: from openfisca_core.simulations.ScenarioSimulation import get_results_dataframe [as 别名]
def test_case(year, save = False):
country = 'france'
salaires_nets = 30000
nmen = 3
nmax = 1
for reforme in [False, True]:
simulation = ScenarioSimulation()
simulation.set_config(year = year,
reforme = reforme,
nmen = nmen,
maxrev = salaires_nets * nmax,
x_axis = 'sali')
# Adding a husband/wife on the same tax sheet (foyer)
simulation.scenario.addIndiv(1, datetime.date(1975, 1, 1), 'conj', 'part')
# simulation.scenario.addIndiv(2, datetime(2000,1,1).date(), 'pac', 'enf')
# simulation.scenario.addIndiv(3, datetime(2000,1,1).date(), 'pac', 'enf')
# Loyers set statut d'occupation
simulation.scenario.menage[0].update({"loyer": 2000})
simulation.scenario.menage[0].update({"so": 4})
simulation.set_param()
simulation.P.ir.autre.charge_loyer.active = 1
simulation.P.ir.autre.charge_loyer.plaf = 1000
simulation.P.ir.autre.charge_loyer.plaf_nbp = 0
print simulation.P
print type(simulation.P)
reduc = 0
print simulation.P.ir.bareme
print len(simulation.P.ir.bareme.thresholds)
for i in range(2, len(simulation.P.ir.bareme.thresholds)):
simulation.P.ir.bareme.setSeuil(i, simulation.P.ir.bareme.thresholds[i] * (1 - reduc))
print simulation.P.ir.bareme
print len(simulation.P.ir.bareme.thresholds)
if simulation.reforme is True:
df = simulation.get_results_dataframe(difference = True)
else:
df = simulation.get_results_dataframe()
print df.to_string()
# Save example to excel
if save:
destination_dir = "c:/users/utilisateur/documents/"
if reforme:
fname = destination_dir + "Trannoy_reforme_new_diff.%s" % "xlsx"
print "Saving " + fname
df.to_excel(fname, sheet_name = "difference")
else:
fname = destination_dir + "Trannoy_reforme_new.%s" % "xlsx"
print "Saving " + fname
df.to_excel(fname, sheet_name = "Trannoy")
示例3: get_couple_with_child_results_datatframe
# 需要导入模块: from openfisca_core.simulations import ScenarioSimulation [as 别名]
# 或者: from openfisca_core.simulations.ScenarioSimulation import get_results_dataframe [as 别名]
def get_couple_with_child_results_datatframe(sali_vous = 0, sali_conj = 0):
simulation = ScenarioSimulation()
simulation.set_config(year = 2013,
nmen = 1)
# Adding a husband/wife on the same tax sheet (ie foyer, as conj) and of course same family (as part)
simulation.scenario.addIndiv(1, datetime.date(1975, 1, 1), 'conj', 'part')
# Adding 1 kids on the same tax sheet and family
simulation.scenario.addIndiv(2, datetime.date(1993, 1, 1), 'pac', 'enf')
# Changing the revenu of the parents
scenario = simulation.scenario
scenario.indiv[0]['sali'] = sali_vous
scenario.indiv[1]['sali'] = sali_conj
# Set the number of major kids in the
scenario.declar[0]['nbJ'] = 1
# Set legislative parameters
simulation.set_param()
# Compute the pandas dataframe of the household case_study
df = simulation.get_results_dataframe()
return df
示例4: test_af2
# 需要导入模块: from openfisca_core.simulations import ScenarioSimulation [as 别名]
# 或者: from openfisca_core.simulations.ScenarioSimulation import get_results_dataframe [as 别名]
def test_af2():
for yr in range(2006, 2010):
print yr
simulation = ScenarioSimulation()
simulation.set_config(year = yr,
nmen = 2,
maxrev = 100000,
x_axis = 'sali')
# Adding a husband/wife on the same tax sheet (foyer)
simulation.scenario.addIndiv(1, datetime.date(1975, 1, 1),
'conj', 'part')
simulation.scenario.addIndiv(2, datetime.date(1975, 2, 2),
'conj', 'part')
simulation.set_param()
# Adding children on the same tax sheet (foyer)
simulation.scenario.addIndiv(3, datetime.date(2000, 1, 1),
'pac', 'enf')
simulation.scenario.addIndiv(4, datetime.date(2000, 1, 1),
'pac', 'enf')
df = simulation.get_results_dataframe(index_by_code = True)
# print df.loc["af"][0]
# print af_2enf[yr]
# print type(df.loc["af"][0])
# print type(af_2enf[yr])
# print abs(df.loc["af"][0] - af_2enf[yr]) < 1e-3
assert abs(df.loc["af"][0] - af_2enf[yr]) < 1e-3
示例5: get_couple_results_dataframe
# 需要导入模块: from openfisca_core.simulations import ScenarioSimulation [as 别名]
# 或者: from openfisca_core.simulations.ScenarioSimulation import get_results_dataframe [as 别名]
def get_couple_results_dataframe(sali_vous_maxrev = 12 * 4000, sali_conj = 12 * 4000, nmen = 11):
# Creating a case_study household with one individual whose taxable income (salaire imposable, sali
# varies from 0 to maxrev = 100000 in nmen = 11 steps
simulation = ScenarioSimulation()
simulation.set_config(year = 2013,
nmen = nmen,
maxrev = sali_vous_maxrev,
x_axis = 'sali')
# Adding a husband/wife on the same tax sheet (ie foyer, as conj) and of course same family (as part)
simulation.scenario.addIndiv(1, datetime.date(1975, 1, 1), 'conj', 'part')
simulation.scenario.indiv[1]['sali'] = sali_conj
# Set legislative parameters
simulation.set_param()
df = simulation.get_results_dataframe()
df2 = df.transpose()[[u'Salaires imposables', u'Impôt sur le revenu']]
df2[u'Salaires imposables vous'] = df2[u'Salaires imposables'] - sali_conj
df2[u'Salaires imposables conj'] = sali_conj
df2.rename(columns = {u'Impôt sur le revenu' : u'Impôt sur le revenu déclaration commune'},
inplace = True)
df2 = df2.drop(u'Salaires imposables', axis=1)
return df2
示例6: test_case_reform
# 需要导入模块: from openfisca_core.simulations import ScenarioSimulation [as 别名]
# 或者: from openfisca_core.simulations.ScenarioSimulation import get_results_dataframe [as 别名]
def test_case_reform(year):
"""
A test case with reform
"""
simulation = ScenarioSimulation()
simulation.set_config(year=year, reforme=True, nmen=1)
# Adding a husband/wife on the same tax sheet (foyer)
simulation.set_param()
test_case = simulation.scenario
sal_mensuel = 1000
for i in range(10):
test_case.indiv[0].update({"sal" + str(i): sal_mensuel * 12})
test_case.indiv[0].update({"nb_trim_val": 50})
test_case.indiv[0].update({"age": 54})
simulation.set_param()
print simulation.P_default
param = simulation.P
# param.pension.rsna.taux_ann_base = .03
param.pension.rsna.age_dep_anticip = 55
df = simulation.get_results_dataframe()
print df.to_string()
示例7: get_alloc
# 需要导入模块: from openfisca_core.simulations import ScenarioSimulation [as 别名]
# 或者: from openfisca_core.simulations.ScenarioSimulation import get_results_dataframe [as 别名]
def get_alloc(maxrev = 10000, conj = False, nbenf = 0, zone_apl = 1, loyer_mensuel = 500, nmen = 51):
# Creating a case_study household with one individual whose taxable income (salaire imposable, sali
# varies from 0 to maxrev = 100000 in nmen = 3 steps
simulation = ScenarioSimulation()
simulation.set_config(year = 2013,
nmen = 11,
maxrev = maxrev,
x_axis = 'sali')
scenario = simulation.scenario
if conj:
# Adding a husband/wife on the same tax sheet (ie foyer, as conj) and of course same family (as part)
scenario.addIndiv(1, datetime.date(1975, 1, 1), 'conj', 'part')
for i in range(nbenf):
# Adding 3 kids on the same tax sheet and family
scenario.addIndiv(2 + nbenf, datetime.date(2001, 1, 1), 'pac', 'enf')
# Add caracteristics of menage
scenario.menage[0]['loyer'] = loyer_mensuel
scenario.menage[0]['zone_apl'] = zone_apl
# Set legislative parameters
simulation.set_param()
# Compute the pandas dataframe of the household case_study
df = simulation.get_results_dataframe()
df2 = df.transpose()[['Salaires imposables', 'Prestations logement']]
return df2
示例8: case_study
# 需要导入模块: from openfisca_core.simulations import ScenarioSimulation [as 别名]
# 或者: from openfisca_core.simulations.ScenarioSimulation import get_results_dataframe [as 别名]
def case_study(year = 2013):
# Creating a case_study household with one individual whose taxable income (salaire imposable, sali
# varies from 0 to maxrev = 100000 in nmen = 3 steps
simulation = ScenarioSimulation()
simulation.set_config(year = 2013,
nmen = 11,
maxrev = 10000,
x_axis = 'sali')
print simulation.scenario
simulation.scenario.addIndiv(1, datetime.date(1975, 1, 1), 'conj', 'part')
print simulation.scenario
simulation.set_param() # Va chercher la legislation par défaut
df = simulation.get_results_dataframe()
print df.to_string()
print simulation.input_table.table.to_string()
print simulation.output_table.table.to_string()
示例9: case_study
# 需要导入模块: from openfisca_core.simulations import ScenarioSimulation [as 别名]
# 或者: from openfisca_core.simulations.ScenarioSimulation import get_results_dataframe [as 别名]
def case_study(year = 2013):
simulation = ScenarioSimulation() #on instancie on prends une instance de ScenarioSimulation, on prends un exemple de cette classe là
simulation.set_config(year = year,
nmen = 4, #nombre de ménages
maxrev = 10000,
x_axis = 'sali')#salaire imposable (une seule personne dans le ménage)
simulation.set_param()#prends les paramètres par défaut de la législation
df = simulation.get_results_dataframe() #renvoie la dataframe avec tout calculé
print df.to_string()
示例10: test_case
# 需要导入模块: from openfisca_core.simulations import ScenarioSimulation [as 别名]
# 或者: from openfisca_core.simulations.ScenarioSimulation import get_results_dataframe [as 别名]
def test_case(year):
simulation = ScenarioSimulation()
simulation.set_config(year=year, reforme=False, nmen=4, maxrev=25 * 9 * 12 * 3, x_axis="sal0")
# Adding a husband/wife on the same tax sheet (foyer)
simulation.set_param()
df = simulation.get_results_dataframe()
print df.to_string()
示例11: test_case
# 需要导入模块: from openfisca_core.simulations import ScenarioSimulation [as 别名]
# 或者: from openfisca_core.simulations.ScenarioSimulation import get_results_dataframe [as 别名]
def test_case(year):
country = 'france'
salaires_nets = 50000
nmen = 100 #nombre de ménages que je fait varier
for reforme in [False, True]: #fais tourner un fois pour faux et une fois pour vrai
#print reforme
simulation = ScenarioSimulation()
simulation.set_config(year = year,
reforme = reforme,
nmen = nmen,
maxrev = salaires_nets,
x_axis = 'sali')
# Adding a husband/wife on the same tax sheet (foyer)
simulation.scenario.addIndiv(1, datetime.date(1975, 1, 1), 'conj', 'part')
# simulation.scenario.addIndiv(2, datetime(2000,1,1).date(), 'pac', 'enf')
# simulation.scenario.addIndiv(3, datetime(2000,1,1).date(), 'pac', 'enf')
# Loyers set statut d'occupation
simulation.scenario.menage[0].update({"loyer": 2000}) #fixe les variables au niveau du ménage
simulation.scenario.menage[0].update({"so": 4}) #
simulation.set_param() #va chercher des params de la législation
simulation.P.ir.autre.charge_loyer.active = 1 #simulation.p est un attribu de simulation
simulation.P.ir.autre.charge_loyer.plaf = 1000
simulation.P.ir.autre.charge_loyer.plaf_nbp = 0
#print simulation.P #montre ce qui est écrit dans param.xml
reduc = 0
#print simulation.P.ir.bareme #change le barème de l'impot sur le revenu
#print simulation.P.ir.bareme.nb #nb de tranche du brarème de l'impot
for i in range(2, simulation.P.ir.bareme.nb):
simulation.P.ir.bareme.setSeuil(i, simulation.P.ir.bareme.seuils[i] * (1 - reduc)) #a partir de la 2nd tranche réduit les seuils des barèmes
#print simulation.P.ir.bareme #nouvea barème
#print simulation.P.ir.bareme.nb
if simulation.reforme is True:
df = simulation.get_results_dataframe(default = True , difference = False) # prends la différence(argument de la fonction getresultdataframe
return df
else:
df = simulation.get_results_dataframe()
示例12: test_nonsal_famille
# 需要导入模块: from openfisca_core.simulations import ScenarioSimulation [as 别名]
# 或者: from openfisca_core.simulations.ScenarioSimulation import get_results_dataframe [as 别名]
def test_nonsal_famille():
"""
test pour un couple de fonctionnaire
"""
tests_list = [
# Couple de microentrepreneur
{"year" : 2013,
"input_vars":
{
"ebic_impv" : 20000,
"ebic_impv_c" : 10000,
},
"output_vars" :
{
"rev_microsocial": (20000 + 10000) - (2820 + 1410),
"microsocial" : 200 + 100,
}
},
]
passed = True
for test in tests_list:
year = test["year"]
simulation = ScenarioSimulation()
simulation.set_config(year = test["year"], nmen = 1)
simulation.set_param()
test_case = simulation.scenario
test_case.addIndiv(1, datetime.date(1975, 1, 1), 'conj', 'part')
for variable, value in test['input_vars'].iteritems():
if variable in ['ebic_impv', 'ebic_imps', 'ebnc_impo']:
test_case.indiv[0].update({variable: value})
elif variable in ['ebic_impv_c', 'ebic_imps_c', 'ebnc_impo_c']:
test_case.indiv[1].update({variable[:-2]: value})
else:
print variable
assert False
for variable, value in test['output_vars'].iteritems():
df = simulation.get_results_dataframe(index_by_code = True)
if variable in df.columns:
val = df.loc[variable][0]
else:
val = simulation.output_table.table[variable][0]
to_test = abs(val - value)
if not (to_test < 1):
print "Il y a une différence : ", to_test
print "Pour le scénario", test['input_vars']
print year
print variable
print "OpenFisca :", val
print "Real value :", value , "\n \n"
assert passed, "Test failed for some variables"
示例13: test_case
# 需要导入模块: from openfisca_core.simulations import ScenarioSimulation [as 别名]
# 或者: from openfisca_core.simulations.ScenarioSimulation import get_results_dataframe [as 别名]
def test_case(year):
simulation = ScenarioSimulation()
simulation.set_config(year = year, reforme = False,
nmen = 3, maxrev = 100000, x_axis = 'sali')
# Adding a husband/wife on the same tax sheet (foyer)
simulation.scenario.addIndiv(1, datetime(1975, 1, 1).date(), 'conj', 'part')
simulation.set_param()
# A the aefa prestation can be disabled by uncommenting the following line
# simulation.disable_prestations( ['aefa'])
df = simulation.get_results_dataframe()
print df.to_string()
示例14: check_test_case
# 需要导入模块: from openfisca_core.simulations import ScenarioSimulation [as 别名]
# 或者: from openfisca_core.simulations.ScenarioSimulation import get_results_dataframe [as 别名]
def check_test_case(year = 2013):
simulation = ScenarioSimulation()
simulation.set_config(year = year, nmen = 2, maxrev = 2000, reforme = False, x_axis = 'sali')
# simulation.scenario.indiv[0]['sali'] = 16207
# # Add husband/wife on the same tax sheet (foyer)
# simulation.scenario.addIndiv(1, datetime.date(1975, 1, 1), 'conj', 'part')
simulation.set_param()
# The aefa prestation can be disabled by uncommenting the following line:
# simulation.disable_prestations( ['aefa'])
df = simulation.get_results_dataframe()
print df.to_string().encode('utf-8')
示例15: test_case
# 需要导入模块: from openfisca_core.simulations import ScenarioSimulation [as 别名]
# 或者: from openfisca_core.simulations.ScenarioSimulation import get_results_dataframe [as 别名]
def test_case(year):
simulation = ScenarioSimulation()
simulation.set_config(year = year, reforme=False, nmen = 3, maxrev = 12*400, x_axis = 'sali')
# Adding a husband/wife on the same tax sheet (foyer)
simulation.scenario.addIndiv(1, datetime(1975,1,1).date(), 'conj', 'part')
simulation.scenario.addIndiv(2, datetime(2000,1,1).date(), 'pac', 'enf')
simulation.scenario.addIndiv(3, datetime(2000,1,1).date(), 'pac', 'enf')
simulation.set_param()
df = simulation.get_results_dataframe()
print df.to_string()