1

I have a dataframe (named energy) with list of countries and other information. The image is shown below.

I want to select only specific countries and their relevant information. The countries I need are selected by another dataframe named SCI_Mago.

How can I do that in pandas? I will write the pseudo code of what I want. I cannot help myself with the exact code and whatever I tried gave me errors.

Pseudo Code

#First I create the list from a dataframe named SCI_Mago. I want these countries for my next data frame
country_list =SCI_Mago['Country'].tolist()

#I use this list to get only relevant countries from another dataframe named 'energy'
new_DF = energy[energy['Country'] ==  country_list]

...

image of dataframe named 'energy'

Community
  • 1
  • 1
jaffry_x
  • 169
  • 1
  • 7

0 Answers0