Created
October 3, 2022 13:21
-
-
Save naenumtou/fbb5f53a4ae67b1ee6cbe93581756b28 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
# Set auto reload | |
%reload_ext autoreload | |
%autoreload 2 | |
# Import libraries | |
import warnings | |
import pandas as pd | |
import numpy as np | |
import statsmodels.api as sm | |
import statsmodels.formula.api as smf | |
from scipy.special import logit | |
# Config | |
%config InlineBackend.figure_format = 'retina' #Retina display | |
warnings.filterwarnings('ignore') #Disable warning | |
# Create regression DataFrame | |
df = pd.concat( | |
[ | |
pd.read_csv( | |
'https://raw.githubusercontent.com/naenumtou/ifrs9/main/PD/datasets/monthlyODR.csv' | |
).query( | |
"Segment == 'CU'" | |
).eval( | |
"ODR = Bad / N" | |
).eval( | |
"logitODR = @logit(ODR)", engine = 'python' | |
)['logitODR'], | |
pd.read_csv( | |
'https://raw.githubusercontent.com/naenumtou/ifrs9/main/PD/datasets/macroTransformed.csv', | |
parse_dates = ['Date'], | |
date_parser = lambda x: pd.to_datetime(x) | |
)[['Date', 'GDP_C_lg12', 'MPI_C_lg12']] | |
], | |
axis = 1 | |
).set_index('Date') | |
# Show table | |
df.head(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment