Homework 8 – FIN535 1 Homework 8 – FIN535 1 You must submit a py file that answers these questions in the console. Use the Industry Portfolios.csv as your test assets, converting them to excess...

1 answer below »

View more »
Answered Same DayOct 29, 2021

Answer To: Homework 8 – FIN535 1 Homework 8 – FIN535 1 You must submit a py file that answers these questions...

Sandeep Kumar answered on Oct 31 2021
155 Votes
{
"cells": [
{
"cell_type": "code",
"execution_count": 71,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import numpy as np\n",
"from sklearn import linear_model\n",
"from pathlib import Path\n"
]
},
{
"cell_type": "code",
"execution_count": 72,
"metadata": {},
"outputs": [],
"source": [
"def clean_dataset(df):\n",
" assert isinstance(df, pd.DataFrame), \"df needs to be a pd.DataFrame\"\n",
" df.dropna(inplace=True)\n",
" indices_to_keep = ~df.isin([np.nan, np.inf, -np.inf]).any(1)\n",
"
return df[indices_to_keep].astype(np.float64)"
]
},
{
"cell_type": "code",
"execution_count": 73,
"metadata": {},
"outputs": [],
"source": [
"stock_csv_path = Path('industryportfolios.csv')\n",
"monthly_df = pd.read_csv(stock_csv_path, index_col = 'Date')\n",
"monthly_df_daily_returns = monthly_df.pct_change()"
]
},
{
"cell_type": "code",
"execution_count": 74,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" ...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here
FoodBeerSmokeGamesBooksHshldClthsHlthChemsTxtls...TelcmServsBusEqPaperTransWhlslRtailMealsFinOther
Date
1930-02-1.003960-1.133566-0.355140-0.3890472.295238-1.861434-1.0869570.235294-0.698898-0.457143...4.883333-2.205732-0.2099680.101717-0.452442-2.485531-2.199552-0.987212-0.366736-1.061989
1930-03-51.500000-8.191304-0.221014-0.075669-0.643064-0.978628-23.8125000.9015873.186992-1.449123...0.245042-0.840238-0.395973-0.2625900.8262910.062771-0.48972031.8000000.409462-4.177665
1930-042.1980200.370012-1.669767-0.698363-0.6153857.052632-1.154795-1.212020-1.5155342.859375...-1.514221-1.044633-1.393333-1.450407-2.830334-1.951120-1.934066-0.504065-1.465278-1.517572
1930-05-0.424149-0.960282-1.645833-1.743215-1.9157893.8692812.7168140.173228-0.559322-0.415992...
April
January
February
March
April
May
June
July
August
September
October
November
December
2025
2025
2026
2027
SunMonTueWedThuFriSat
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
00:00
00:30
01:00
01:30
02:00
02:30
03:00
03:30
04:00
04:30
05:00
05:30
06:00
06:30
07:00
07:30
08:00
08:30
09:00
09:30
10:00
10:30
11:00
11:30
12:00
12:30
13:00
13:30
14:00
14:30
15:00
15:30
16:00
16:30
17:00
17:30
18:00
18:30
19:00
19:30
20:00
20:30
21:00
21:30
22:00
22:30
23:00
23:30