-
Introduction 1
-
Lecture1.1
-
-
Getting the Data 3
-
Lecture2.1
-
Lecture2.2
-
Lecture2.3
-
-
SP500 Webscrape 4
-
Lecture3.1
-
Lecture3.2
-
Lecture3.3
-
Lecture3.4
-
-
Full Dataset 2
-
Lecture4.1
-
Lecture4.2
-
-
Regressions 5
-
Lecture5.1
-
Lecture5.2
-
Lecture5.3
-
Lecture5.4
-
Lecture5.5
-
-
Machine Learning 5
-
Lecture6.1
-
Lecture6.2
-
Lecture6.3
-
Lecture6.4
-
Lecture6.5
-
-
Machine Learning Function 2
-
Lecture7.1
-
Lecture7.2
-
-
Visualize Data 2
-
Lecture8.1
-
Lecture8.2
-
Making the Beta Dataframe Part 2
Solution
df2 = pd.DataFrame()
for stock in df.columns[:-4]:
frame = regress(stock)
df2 = pd.concat([df2,frame], axis=1)
print(df2)
We do df.columns[:-4] so that we don’t run the regressions on our indicator variables (they’re the last four columns).
Save!
df2.to_csv("RegressionMatrix1.csv",encoding="UTF-8")
Source Code
Next
Introduction