I am currently struggling with a small problem which I would be very about to be resolved here. I have a predefined matrix which looks like this:
AUS AUT BEL
AUS
AUT
BEL
and I have a pandas Dataframe which looks like this:
country1 country2 agreements
AUS AUT 1
AUS BEL 3
AUT AUS 3
AUT BEL 2
BEL AUS 5
BEL AUT 3
Now I would like to "search" the DataFrame for every index and column name and insert the value from the agreements column. The result should then look like this:
AUS AUT BEL
AUS 1 3
AUT 3 2
BEL 5 3
As the DataFrame also contains names / countries which do not match the matrix they should be ignored, or if no value is available NAN should be inserted. Does someone know how to handle, solve this?
Thank you in advance!