Electricity price in Portugal
- jorge pinheiro

- 20 de mai. de 2021
- 2 min de leitura
Atualizado: 6 de jun. de 2021
This article compares the price of electricity across the different european countries, showing the unbalance between earnings and electricity cost in Portugal. For that it was used the eurostat database and the programming language Python.
Step 1: import the needed libraries and find the needed eurostat databases.
# import the libraries
import pandas as pd
import eurostat
# import the database names
toc_df = eurostat.get_toc_df()
toc_df.describe()
# find specific databases based on a string
[i for i in toc_df.title if "Final energy consumption in households" in i]
# or
eurostat.subset_toc_df(toc_df, "Final energy consumption in households")
Step 2: import the needed eurostat databases.
# find the databases codes and import the databases
# Final energy consumption in households
cod = toc_df.loc[9079,'code']
cons_house = eurostat.get_data_df(cod)
cons_house.head()
cons_house.shape
cons_house = cons_house.loc[:,['geo\\time','unit',2019]]
cons_house.columns = ['geo','unit_ch','2019_ch']
cons_house.index = cons_house['geo']
# Final energy consumption in households per capita
cod = toc_df.loc[8528,'code']
cons_house_pc = eurostat.get_data_df(cod)
cons_house_pc.head()
cons_house_pc = cons_house_pc.loc[:,['geo\\time','unit',2019]]
cons_house_pc.columns = ['geo','unit_chpc','2019_chpc']
cons_house_pc.index = cons_house_pc['geo']
# Final energy consumption in households by type of fuel
cod = toc_df.loc[8519,'code']
cons_house_tf = eurostat.get_data_df(cod)
cons_house_tf.head()
cons_house_tf['siec'].unique()
# Final electricity consumption in households
cons_house_tf = cons_house_tf.loc[cons_house_tf.siec=='E7000',['siec','unit','geo\\time',2019]]
cons_house_tf.columns = ['siec','unit_ech','geo','2019_ech']
cons_house_tf.index = cons_house_tf['geo']
# Annual net earnings
cod = 'earn_nt_net'
earn = eurostat.get_data_df(cod)
earn.head()
earn.columns
for i in ['currency','estruct','ecase']:
earn[i].unique()
# Two-earner couple with two children, both earning 100% of the average earning
earn = earn.loc[(earn.estruct=='NET') & (earn.currency=='EUR') & (earn.ecase=='CPL_CH2_AW100_100'), ['geo\\time',2019]]
earn.columns = ['geo','2019_earn']
earn.index = earn['geo']
# Electricity prices (VAT and consumption)
cod = 'nrg_pc_204_c'
prices = eurostat.get_data_df(cod)
prices.head()
prices.columns
for i in ['nrg_cons','nrg_prc','currency']:
prices[i].unique()
prices_vat = prices.loc[(prices.nrg_cons=='TOT_KWH') & (prices.nrg_prc=='VAT') & (prices.currency=='EUR'),['geo\\time','2019']]
prices_vat.columns = ['geo','2019_prvat']
prices_vat.index = prices_vat['geo']
prices_eng = prices.loc[(prices.nrg_cons=='TOT_KWH') & (prices.nrg_prc!='VAT') & (prices.currency=='EUR'),['geo\\time','2019']].groupby(['geo\\time']).sum()
prices_eng.columns = ['2019_preng']
Step 3: join the dataframes and calculate the needed variables.
# join the data
energy = pd.concat([cons_house, cons_house_pc, cons_house_tf, earn, prices_vat, prices_eng], axis=1, join='outer', sort=False)
energy.columns
energy['geo'] = energy.index
# calculate the households electricty consumption per capita
energy['2019_echpc'] = energy['2019_ech'] * energy['2019_chpc'] / energy['2019_ch']
# calculate the households cost with electricty consumption with VAT per capita
energy['2019_ecthpc'] = energy['2019_echpc'] * (energy['2019_preng'] + energy['2019_prvat'])
Step 4: calculate the rankings of UE countries.
geo = ['NL', 'AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'EL', 'ES', 'FI', 'FR', 'HU', 'IE', 'IT', 'LT', 'LU', 'LV', 'NL', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK']
# households cost with electricty consumption with VAT per capita, portuguese ranking
energy.loc[geo,'2019_ecthpc'].rank(ascending=False)['PT']
# two-earner couple with one children, both earning 100% of the average earning, portuguese ranking
energy.rank(ascending=False).loc['PT','2019_earn']
# calculate the european countries average of the households electricty consumption per capita
mean_echpc = energy['2019_echpc'].mean()
# calculate the households cost with electricty consumption with VAT per capita if europeans consumption was equal
energy['2019_mecthpc'] = mean_echpc * (energy['2019_preng'] + energy['2019_prvat'])
Step 5: verifying Portugal's rankings
# households cost with electricty consumption with VAT per capita, portuguese ranking
energy.loc[geo, '2019_ecthpc'].rank(ascending=False)['PT']
# two-earner couple with one children, both earning 100% of the average earning, portuguese ranking
energy.loc[geo, '2019_earn'].rank(ascending=False).loc['PT']
# calculate the european countries average of the households electricty consumption per capita
mean_echpc = energy['2019_echpc'].mean()
# calculate the households cost with electricty consumption with VAT per capita if europeans consumption was equal
energy['2019_mecthpc'] = mean_echpc * (energy['2019_preng'] + energy['2019_prvat'])
# households cost with electricty consumption with VAT per capita if europeans consumption was equal, portuguese ranking
energy.loc[geo, '2019_mecthpc'].rank(ascending=False).loc['PT']
Conclusion:
Portugal has the 7th households cost with electricty consumption with VAT per capita higher in EU but, if we look to the earnings of a typical family with two-earner couple and one children, both earning 100% of the average earning, Portugal is in the 17th position. If we look just for the electricity consumption cost, we can conclude that Portugal has even an higher position.





Comentários