SHARE
TWEET

Untitled

a guest Jun 19th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. df = pd.DataFrame({'Timestamp': [datetime.date(2019, 4, 15), datetime.date(2019, 4, 16), datetime.date(2019, 4, 17), datetime.date(2019, 4, 18), datetime.date(2019, 4, 19), datetime.date(2019, 4, 20), datetime.date(2019, 4, 21), datetime.date(2019, 4, 22), datetime.date(2019, 4, 23), datetime.date(2019, 4, 24), datetime.date(2019, 4, 25), datetime.date(2019, 4, 26), datetime.date(2019, 4, 27), datetime.date(2019, 4, 28)], 'Price': ['3988', '3988', '3988', '3988', '3988', '3988', '3988', '3988', '3988', '3988', '3988', '3988', '3988', '3988']})
  2. df['Timestamp'] = pd.to_datetime(df['Timestamp'])
  3. df['Price'] = df['Price'].astype('int')
  4.      
  5. df['Week'] = [1 if x == 4 else 0 for x in df['Timestamp'].dt.weekday]
  6. df['Week'] = df['Week'].cumsum()
  7.      
  8. df[['Price', 'Week']].groupby('Week').mean()
  9.      
  10. df[['Timestamp', 'Week']].groupby(['Week']).agg({'Timestamp':[np.min,np.max]})
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top