daily pastebin goal
86%
SHARE
TWEET

Untitled

a guest Jun 17th, 2018 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Trade = pd.read_csv('data/Trade.csv')
  2. Trade = Trade[Trade['TradeDateKey'] > 20160101]
  3. # Trade = Trade[Trade['TradeStatus'] != 'Holding']
  4.  
  5.  
  6. Trade['datetime'] = pd.to_datetime(Trade['TradeDateKey'].astype(str).apply(f))
  7. Trade['is_month_end'] = Trade['datetime'].dt.is_month_end
  8.  
  9. Trade['dayofweek'] = Trade['datetime'].dt.dayofweek
  10. Trade['day_of_week_start'] = Trade['TradeDateKey'] - Trade['dayofweek']
  11.  
  12. Trade = Trade[Trade['is_month_end'] != True]
  13. Trade = Trade.drop(['is_month_end'] , axis=1)
  14.  
  15. Trade['BuySell'] = Trade['BuySell'].apply(lambda x: mapa[x])
  16.  
  17. week_mapa = {}
  18. for k, i in enumerate(np.sort(Trade['day_of_week_start'].unique())):
  19.     week_mapa[i] = k
  20.  
  21. Trade['week_id'] = Trade['day_of_week_start'].apply(lambda x: week_mapa[x])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top