0

I have used this code in order to make a dataframe that contains GDP, import, export but it gives data from 1960 to 2020 but I want data from 2010 to 2020 only can you please suggest answers?

import wbdata
import pandas
import matplotlib.pyplot as plt
 
#set up the countries I want
countries = ["CL","UY","HU"]
 
#set up the indicator I want (just build up the dict if you want more than one)
indicators = {'NY.GNP.PCAP.CD':'GNI per Capita'}
 
#grab indicators above for countires above and load into data frame
df = wbdata.get_dataframe(indicators, country=countries, convert_date=False)

#df is "pivoted", pandas' unstack fucntion helps reshape it into something plottable
dfu = df.unstack(level=0)

# a simple matplotlib plot with legend, labels and a title
dfu.plot(); 
plt.legend(loc='best'); 
plt.title("GNI Per Capita ($USD, Atlas Method)"); 
plt.xlabel('Date'); plt.ylabel('GNI Per Capita ($USD, Atlas Method');

Also additionally I want to add one more column named openness index which is (import + export)/GDP then how can I do the same?

I had not prior experience thus tried nothing please provide some relevant resources or solution to perform these operations.

I tried the following but did not work enter image description here

tom01
  • 3
  • 3

0 Answers0