# -*- coding: utf-8 -*-
"""pyp2test.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1JaGyRkKK3UT4q5GbyB0R5gcIZGN41pQg
"""

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import openpyxl
def main ():
 d1=pd.read_excel('https://sipri.org/sites/default/files/SIPRI-Milex-data-1949-2020_0.xlsx',engine='openpyxl',sheet_name='Constant (2019) USD',header=4,index_col=0)
 d1.columns=d1.iloc[0]
 d2=pd.read_excel('https://sipri.org/sites/default/files/SIPRI-Milex-data-1949-2020_0.xlsx',engine='openpyxl',sheet_name='Per capita',header=5,index_col=0)
 d2.columns=d2.iloc[0]
 d3=pd.read_excel('https://sipri.org/sites/default/files/SIPRI-Milex-data-1949-2020_0.xlsx',engine='openpyxl',sheet_name='Share of GDP',header=4,index_col=0)
 d3.columns=d3.iloc[0]

 us=pd.DataFrame((d1.loc['USA'].loc[1995:2020],d2.loc['USA'].loc[1995:2020],d3.loc['USA'].loc[1995:2020]),index=['total','per','gdp'])
 rus=pd.DataFrame((d1.loc['Russia'].loc[1995:2020],d2.loc['Russia'].loc[1995:2020],d3.loc['Russia'].loc[1995:2020]),index=['total','per','gdp'])
 ukr=pd.DataFrame((d1.loc['Ukraine'].loc[1995:2020],d2.loc['Ukraine'].loc[1995:2020],d3.loc['Ukraine'].loc[1995:2020]),index=['total','per','gdp'])
 uk=pd.DataFrame((d1.loc['UK'].loc[1995:2020],d2.loc['UK'].loc[1995:2020],d3.loc['UK'].loc[1995:2020]),index=['total','per','gdp'])

 fig,ax1=plt.subplots(figsize=(8,8))
 ax1.plot()
 ax1.set_ylabel('total')
 g1=plt.plot(ukr.iloc[0],color='orange',label='Ukraine total')
 g2=plt.plot(rus.iloc[0],color='red',label='Russia total')
 g3=plt.plot(uk.iloc[0],color='pink',label='UK total')
 g4=plt.plot(us.iloc[0],color='magenta',label='USA total')
 plt.legend(loc='upper right')
 ax2=ax1.twinx()
 ax2.plot()
 ax2.set_ylabel('per')
 g1=plt.plot(ukr.iloc[1],color='blue',label='Ukraine per')
 g2=plt.plot(rus.iloc[1],color='green',label='Russia per')
 g3=plt.plot(uk.iloc[1],color='white',label='UK per')
 g4=plt.plot(us.iloc[1],color='black',label='USA per')
 plt.legend(loc='lower right')
 ax3=ax2.twinx()
 ax3.plot()
 ax3.set_ylabel('gdp')
 g5=plt.plot(ukr.iloc[2],color='grey',label='Ukraine gdp')
 g6=plt.plot(rus.iloc[2],color='black',label='Russia gdp')
 g3=plt.plot(uk.iloc[2],color='cyan',label='UK gdp')
 g4=plt.plot(us.iloc[2],color='purple',label='USA gdp')
 plt.legend(loc='upper left')
 print(us.T.loc[2010:2020])
 print(rus.T.loc[2010:2020])
 print(ukr.T.loc[2010:2020])
 print(uk.T.loc[2010:2020])
main()