I have four worksheets within the same Workbook. Each of four sheets is shown below:
- General Assumption Sheet
- Ref Tariff Sheet
- Plant Parameter Sheet
- Indexed Tariff Sheet (need to populate this with Vlookups and Hlookups)
I have been trying to use both Vlookup and Hlookup in Python to match the plant name and year to get the desired value but I am getting errors.
To populate the Indexed Tariff Sheet, I need to match the Plant name in it with:
the same plant name e.g. Engro_PWR which has a value of 0.0501, in Ref Tariff Sheet. Then,
Multiply that value ( i.e. 0.0501) with the US CPI(in General Assumption Sheet) / US CPI (Plant Parameter Sheet) after matching both the years and plant names.
For example if the year is 2022 and Plant is Engro_PWR , then it becomes 0.0501*(269.73/216.74)
I am using Openpyxl only at the moment.
Any help would be very appreciated.
Code:
current_year=indexed_tariff['C1'].value
column_cell = 3
i='Engro_PWR'
if indexed_tariff['C1'].value <= 2027 and indexed_tariff['C1'].value > 1997:
vlookup=pd.merge(data_FuelCost,to_dframe[['Fuel Price (Ref Values-Yearly)','Fuel Cost (Reference)']], on='Fuel Price (Ref Values-Yearly)',how='left')
indexed_tariff[column_cell+str(row+5)] = str(i)
data_FuelCost is Ref Tariff Sheet
Error:
KeyError: "['Fuel Cost (Reference)'] not in index"



