Python Forum
Matrix Search and Calculation Pandas
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Matrix Search and Calculation Pandas
#1
Dear all,

I have problems with a matrix search and calculation. This is my problem.
I have a df1 with different year values for each indicator and country.
I have a df2 with combinations of countries and yearly values.
The desired output is df3 where the product of the indicators fo the countires per year is created and calcualted.

These are the Dataframe:

df1 =pd.DataFrame({'Country':['Armenia','Azerbaidjan','Belarus','Armenia','Azerbaidjan','Belarus'],\
             'Indictaor':['G','G','G','H', 'H', 'H'],'2005':[3,4,5,6,7,4],'2006':[6,3,1,3,5,6]})
 	

[python]
df2 = pd.DataFrame({'Year':[2005,2006,2005,2006],
                    'Country1':['Armenia','Armenia','Azerbaidjan','Azerbaidjan'],
                    'Country2': ['Belarus','Belarus','Belarus','Belarus']})
df3 = pd.DataFrame({'Year':[2005,2006,2005,2006],                   
                    'Country2': ['Belarus','Belarus','Belarus','Belarus'],
                    'Country1':['Armenia','Armenia','Azerbaidjan','Azerbaidjan'],
                     'IndictaorGProduct':[15,6,35,5],
                      'IndictaorHProduct':[24,18,28,30]})
I am extremly thankful if someone could help with this problem as this is really confusing.

Thank you.

Kidn regards
Reply


Messages In This Thread
Matrix Search and Calculation Pandas - by luxlambo227 - Jan-21-2020, 11:22 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to search for specific string in Pandas dataframe Coding_Jam 1 2,452 Nov-02-2020, 09:35 AM
Last Post: PsyPy
  Trying to Pass date to pandas search from input prompt curranjohn46 1 2,132 Oct-10-2019, 10:01 AM
Last Post: curranjohn46
  Calculation using group by and pandas sarabi1005 0 2,232 Aug-29-2017, 08:13 PM
Last Post: sarabi1005

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020