-
-
Save BinarySpoon/b09e5e3afb69ed95ff9d4b4105bfe4f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get recession start --> | |
def get_recession_start(): | |
gdplev = pd.read_excel('gdplev.xls',skiprows=219) | |
data = gdplev.copy() | |
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['GDP+1'] = data.GDP.shift(-1) #gdp of next quarter | |
data['GDP-1'] = data.GDP.shift(1) #gdp of prev quarter | |
data = data[(data['GDP-1']>data['GDP']) & (data['GDP']>data['GDP+1'])] | |
data = data[['GDP-1','GDP','GDP+1']].dropna() | |
return data.index[0] | |
get_recession_start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment