Reputation: 63
I get the following tuples with my code:
('20170517 12:00:00', 2386.0, 2387.0, 2385.75, 2385.75, 9367)
('20170517 12:10:00', 2386.25, 2386.25, 2385.0, 2385.25, 7126)
('20170517 12:20:00', 2385.0, 2386.0, 2384.75, 2385.0, 7546)
('20170517 12:30:00', 2385.25, 2385.5, 2384.5, 2384.75, 10492)
('20170517 12:40:00', 2384.75, 2385.75, 2384.25, 2384.25, 7792)
('20170517 12:50:00', 2384.25, 2385.5, 2384.0, 2385.25, 10444)
('20170517 13:00:00', 2385.25, 2385.5, 2384.75, 2385.25, 6508)
('20170517 13:10:00', 2385.25, 2385.75, 2385.0, 2385.25, 8363)
('20170517 13:20:00', 2385.25, 2385.75, 2385.25, 2385.25, 7093)
('20170517 13:30:00', 2385.5, 2386.0, 2385.25, 2385.5, 6724)
('20170517 13:40:00', 2385.5, 2385.5, 2385.0, 2385.5, 8856)
('20170517 13:50:00', 2385.25, 2385.5, 2384.75, 2385.25, 9058)
I convert the tuples to Dataframe with the this code:
df = pd.DataFrame(data, columns=['Date', 'Open', 'Close', 'High', 'Low', 'Volume'])
and I get:
Date Open Close High Low Volume
222 20170517 12:00:00 2386.00 2387.00 2385.75 2385.75 9367
223 20170517 12:10:00 2386.25 2386.25 2385.00 2385.25 7126
224 20170517 12:20:00 2385.00 2386.00 2384.75 2385.00 7546
225 20170517 12:30:00 2385.25 2385.50 2384.50 2384.75 10492
226 20170517 12:40:00 2384.75 2385.75 2384.25 2384.25 7792
227 20170517 12:50:00 2384.25 2385.50 2384.00 2385.25 10444
228 20170517 13:00:00 2385.25 2385.50 2384.75 2385.25 6508
229 20170517 13:10:00 2385.25 2385.75 2385.00 2385.25 8363
230 20170517 13:20:00 2385.25 2385.75 2385.25 2385.25 7093
231 20170517 13:30:00 2385.50 2386.00 2385.25 2385.50 6724
232 20170517 13:40:00 2385.50 2385.50 2385.00 2385.50 8856
233 20170517 13:50:00 2385.25 2385.50 2384.75 2385.50 9181
234 20170517 14:00:00 2385.25 2385.75 2385.00 2385.50 2667
The only problem i got is that I don't know how to set the Date column to Index. Anyone?
Upvotes: 0
Views: 185
Reputation: 63
Conveniently, there's a set_index
function that allows you to specify a column as the index.
df2 = df.set_index('Date')
Upvotes: 1