I have a pandas dataframe monthlyTempDiff with contents as:
monthlyAdder.ix[1:3]
City1 City2 City3
monthID
1 0.01 0.1 0.02
2 0.04 0.2 0.03
8 0.17 0.3 0.05
Column monthID is also the index.
I have another table fwdTempTable
fwdTempTable.ix[1:3]
City1 City2 City3 City4 monthID
DateTime
2017-1-01 22 24 26 16 1
2017-8-01 23 25 27 17 8
2017-2-01 13 15 17 27 2
I want to add to fwdTempTable, data from monthlyAdder based on combination of monthID and City1, City2, City3 to obtain the following:
fwdTempTable.ix[1:3]
City1 City2 City3 City4 monthID
DateTime
2017-1-01 22.01 24.1 26.02 16 1
2017-8-01 23.17 25.3 27.05 17 8
2017-2-01 13.04 15.2 17.03 27 2
i.e. for each row of dataframe fwdTempTable, I extract the City1, City2 or City3 category and map it along with monthID to dataframe monthlyAdder. After mapping to monthlyAdder, I will get the right adder for a city and a month. I adjust the city data in fwdTempTable with this adder for that month.
These dataframes are large and I can't think beyond for loop on each column of fwdTempTable.