Dataframe 1 looks like this:
df1 = pd.DataFrame(
{
"Farm ID": ["1", "2", "2", "3", "3"],
"Crop": ["Type A", "Type A", "Type B", "Type B", "Type B"],
"Area": [8, 4, 2, 3, 5],
"Diesel": [101, 215, 3, 0.6, 42],
}
)
df1 = df1.set_index(['Farm ID', 'Crop'])
df1
Dataframe 2 looks like this:
df2 = pd.DataFrame(
{
"Name": ["Area", "Diesel"],
"GHG": [690, 8.5],
"LU": [2.2, 0.3],
}
)
df2 = df2.set_index('Name')
df2
I now need to combine both such that I receive the following information:
GHG LU
Farm ID Crop Name
1 Type A Area 8*690 8*2.2
Diesel 101*690 101*2.2
2 Type A Area 4*690 4*2.2
Diesel 215*690 215*2.2
Type B Area ....
Any suggestions welcome as I am completely clueless. I also take ideas if there are better ways to structure this. I will have to do further analysis (e.g. aggregation by crop type or name, and similar) on the resulting dataframe and might think too complicated... Thanks a lot!