daily pastebin goal
1%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2. import pandas as pd
  3. import scipy.stats as ss
  4.  
  5. def create_combined_vector(assessment_file):      
  6.    
  7.     comb_df = pd.read_csv(assessment_file)
  8.    
  9.     # Seperate out vectors
  10.     days  = [0 for i in range(len(comb_df.values))]
  11.     trend = comb_df['trend'].values
  12.     close = comb_df['adjusted_close'].values
  13.  
  14.     # Resize and normalize                                                                                
  15.     days  = days[1:]
  16.     trend = ss.zscore(trend[1:])
  17.     close = ss.zscore(np.diff(close))
  18.  
  19.     return (trend, close, days)
  20.  
  21. # Generate combined vecotr ready for ingestion by the
  22. # Granger Causality function (days used for later graph)
  23. (trend, close, days) = create_combined_vector(filename)
  24. combined_vector = []
  25. for i in range(len(trend)):
  26.     combined_vector.append((trend[i], close[i]))
RAW Paste Data
Top