In [1]:
from __future__ import division
import pandas
import seaborn
from pandas import concat
In [2]:
from openfisca_france_indirect_taxation.examples.utils_example import graph_builder_line
from openfisca_france_indirect_taxation.surveys import SurveyScenario
In [3]:
seaborn.set_palette(seaborn.color_palette("Set2", 12))
%matplotlib inline
In [4]:
simulated_variables = [
'revtot',
'somme_coicop12_conso',
'rev_disp_loyerimput',
'ticpe_totale',
'diesel_ticpe',
'essence_ticpe'
]
In [5]:
for element in ['ticpe_totale', 'diesel_ticpe', 'essence_ticpe']:
revtot = None
rev_disp_loyerimput = None
depenses = None
for year in [2000, 2005, 2011]:
survey_scenario = SurveyScenario.create(year = year)
pivot_table = pandas.DataFrame()
for values in simulated_variables:
pivot_table = pandas.concat([
pivot_table,
survey_scenario.compute_pivot_table(values = [values], columns = ['niveau_vie_decile'])
])
df = pivot_table.T
part_revtot = pandas.DataFrame()
part_revtot['part ' + element.replace('_', ' ') + ' revtot {}'.format(year)] = \
df[element] / df['revtot']
part_rev_loyerimput = pandas.DataFrame()
part_rev_loyerimput['part ' + element.replace('_', ' ') + ' rev disp loyerimput {}'.format(year)] = \
df[element] / df['rev_disp_loyerimput']
part_depenses = pandas.DataFrame()
part_depenses['part ' + element.replace('_', ' ') + ' depenses {}'.format(year)] = \
df[element] / df['somme_coicop12_conso']
if revtot is not None:
revtot = concat([revtot, part_revtot], axis = 1)
else:
revtot = part_revtot
if rev_disp_loyerimput is not None:
rev_disp_loyerimput = concat([rev_disp_loyerimput, part_rev_loyerimput], axis = 1)
else:
rev_disp_loyerimput = part_rev_loyerimput
if depenses is not None:
depenses = concat([depenses, part_depenses], axis = 1)
else:
depenses = part_depenses
graph_builder_line(revtot)
graph_builder_line(rev_disp_loyerimput)
graph_builder_line(depenses)