Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
plotting data clusters sorted by the date

hey guys,
can someone help my with plotting sets of data from my dataset?

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import math
import datetime
from time import time

t = time()

print t

print str(datetime.now())

start = '2015-01-01'
end = '2017-01-01'

context.spy = sid(8554)

data = get_pricing(['SPY'], fields='price', frequency='minute', start_date=start, end_date=end)
data_volume = get_pricing(['SPY'], fields='volume', frequency='minute', start_date=start, end_date=end)
data = data.tz_convert('US/Eastern')
date_range = pd.date_range(start, end, frequency='daily')
data['Date'] = data.index.date
time_9_31 = datetime.time(9, 31)
time_12_00 = datetime.time(12, 0)

Use the '.time' property of index to select only indexes at the times

data = data.loc[(data.index.time==time_9_31) | (data.index.time==time_12_00)]

print date_range

data.columns = [e.symbol for e in data.columns]

data['percent_change'] = data.groupby('Date').pct_change()
data.head()

plt.plot(data['percent_change'] > 0)

plt.plot(data['percent_change'] <= 0)

print (data['percent_change'])

2015-01-02 09:31:00-05:00 NaN
2015-01-02 09:32:00-05:00 0.000197
2015-01-02 09:33:00-05:00 0.001066
2015-01-02 09:34:00-05:00 0.000338
2015-01-02 09:35:00-05:00 -0.000535
2015-01-02 09:36:00-05:00 0.000570
2015-01-02 09:37:00-05:00 0.000111
2015-01-02 09:38:00-05:00 0.000096
2015-01-02 09:39:00-05:00 0.000242
2015-01-02 09:40:00-05:00 0.000045
2015-01-02 09:41:00-05:00 0.000146
2015-01-02 09:42:00-05:00 -0.000242
2015-01-02 09:43:00-05:00 0.000192
2015-01-02 09:44:00-05:00 -0.000338
2015-01-02 09:45:00-05:00 -0.000287
2015-01-02 09:46:00-05:00 -0.000338
2015-01-02 09:47:00-05:00 0.000288
2015-01-02 09:48:00-05:00 -0.000530
2015-01-02 09:49:00-05:00 -0.000242
2015-01-02 09:50:00-05:00 0.000000
2015-01-02 09:51:00-05:00 -0.000025
2015-01-02 09:52:00-05:00 0.000121
2015-01-02 09:53:00-05:00 0.000146
2015-01-02 09:54:00-05:00 -0.000389
2015-01-02 09:55:00-05:00 -0.000631
2015-01-02 09:56:00-05:00 0.000096
2015-01-02 09:57:00-05:00 0.000293
2015-01-02 09:58:00-05:00 0.000389
2015-01-02 09:59:00-05:00 -0.000439
2015-01-02 10:00:00-05:00 0.000121
...
2016-12-30 15:31:00-05:00 0.000045
2016-12-30 15:32:00-05:00 -0.000291
2016-12-30 15:33:00-05:00 -0.000246
2016-12-30 15:34:00-05:00 0.000246
2016-12-30 15:35:00-05:00 -0.000067

the first is the beginning oy my code and the output. i want to group data with the same date and print a line in a graph for every date..this shouldnt be too difficult normaly..thanks in advance