In [1]:
import os
import sys
import random
import time
from random import seed, randint
import argparse
import platform
from datetime import datetime
import imp
import numpy as np
import fileinput
from itertools import product
import pandas as pd
from scipy.interpolate import griddata
from scipy.interpolate import interp2d
import seaborn as sns
from os import listdir

import matplotlib.pyplot as plt
import seaborn as sns
from scipy.interpolate import griddata
import matplotlib as mpl
sys.path.insert(0,'..')
from notebookFunctions import *
# from .. import notebookFunctions

%matplotlib inline
plt.rcParams['figure.figsize'] = (10,6.180)    #golden ratio
# %matplotlib notebook
%load_ext autoreload
%autoreload 2

In [4]:
year = np.arange(2018,2051)

In [5]:
def GDP_change(year, rate=0.06):
    return (1+rate)**(year-year[0])

In [7]:
china = 11.2*GDP_change(year,rate=0.06)

In [8]:
us = 18.57*GDP_change(year,rate=0.02)

In [11]:
pd.DataFrame(np.concatenate([year, china,us], axis=1))


---------------------------------------------------------------------------
AxisError                                 Traceback (most recent call last)
<ipython-input-11-ea9be3debe19> in <module>()
----> 1 pd.DataFrame(np.concatenate([year, china,us], axis=1))

AxisError: axis 1 is out of bounds for array of dimension 1

In [20]:
c = pd.Series(china,name="china")
u = pd.Series(us,name="us")
y = pd.Series(year,name="year")

In [23]:
data = pd.concat([y,c,u],axis=1)
data.plot("year", ["china","us"],figsize=(20,12.36))

In [28]:
y = pd.DataFrame(year,name="year")


Out[28]:
<matplotlib.axes._subplots.AxesSubplot at 0x1a211a1048>

In [44]:
pd.DataFrame(data=year, columns=["year"]).assign(china=11.2*GDP_change(year,rate=0.06)).\
    assign(us=18.57*GDP_change(year,rate=0.02))


Out[44]:
year china us
0 2018 11.200000 18.570000
1 2019 11.872000 18.941400
2 2020 12.584320 19.320228
3 2021 13.339379 19.706633
4 2022 14.139742 20.100765
5 2023 14.988126 20.502781
6 2024 15.887414 20.912836
7 2025 16.840659 21.331093
8 2026 17.851098 21.757715
9 2027 18.922164 22.192869
10 2028 20.057494 22.636726
11 2029 21.260944 23.089461
12 2030 22.536600 23.551250
13 2031 23.888797 24.022275
14 2032 25.322124 24.502721
15 2033 26.841452 24.992775
16 2034 28.451939 25.492631
17 2035 30.159055 26.002483
18 2036 31.968599 26.522533
19 2037 33.886714 27.052983
20 2038 35.919917 27.594043
21 2039 38.075112 28.145924
22 2040 40.359619 28.708842
23 2041 42.781196 29.283019
24 2042 45.348068 29.868680
25 2043 48.068952 30.466053
26 2044 50.953089 31.075374
27 2045 54.010275 31.696882
28 2046 57.250891 32.330820
29 2047 60.685944 32.977436
30 2048 64.327101 33.636985
31 2049 68.186727 34.309724
32 2050 72.277931 34.995919

In [55]:
rate_list = np.linspace(0.03, 0.1)

In [56]:
N = np.log(18.57/11.2)/(np.log((1+rate_list)/(1.0+0.02)))

In [57]:
plt.plot(rate_list, N)


Out[57]:
[<matplotlib.lines.Line2D at 0x1a22090278>]

In [ ]: