Skip to content

Commit 85a27ab

Browse files
author
jiaqi
committed
video 3
1 parent 9b95486 commit 85a27ab

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Diff for: Regression_Features_and_Labels_p2.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import pandas as pd
2+
import quandl
3+
import math
4+
5+
df = quandl.get('WIKI/GOOGL')
6+
7+
df = df[['Adj. Open','Adj. High','Adj. Low','Adj. Close','Adj. Volume']]
8+
df['HL_PCT']=(df['Adj. High']-df['Adj. Close'])/df['Adj. Close']*100
9+
df['PCT_change']=(df['Adj. Close']-df['Adj. Open'])/df['Adj. Open']*100
10+
df=df[['Adj. Close','HL_PCT','PCT_change','Adj. Volume']]
11+
12+
forecast_col='Adj. Close'
13+
df.fillna(-99999,inplace=True)
14+
15+
forecast_out=int(math.ceil(0.01*len(df)))
16+
17+
df['label']=df[forecast_col].shift(-forecast_out)
18+
df.dropna(inplace=True)
19+
print(df.head())

0 commit comments

Comments
 (0)