Skip to content

Instantly share code, notes, and snippets.

@BinarySpoon
Last active October 23, 2020 10:06
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
# get recession end -->
def get_recession_end():
data = pd.read_excel('gdplev.xls',skiprows=219)
data = data.rename(columns={data.columns[4]:'Quaters',data.columns[6]:'GDP'})
data.set_index('Quaters',inplace=1)
data.sort_index(axis=0,inplace=1)
data['GDP1'] = data.GDP.shift(-1) #gdp of next quarter
data['GDP-1'] = data.GDP.shift(1) #gdp of prev quarter
RecessionQ = get_recession_start()
data = data[data.index>RecessionQ]
data = data[(data['GDP-1']<data['GDP']) & (data['GDP']<data['GDP1'])]
data = data[['GDP-1','GDP','GDP1']].dropna()
return data.index[1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment