-
-
Save andrewwxy/d48d81559a95a0d59e8d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Save stock ticker data from Yahoo! Finance to sqlite. | |
""" | |
import datetime as d | |
import sqlite3 | |
import pandas.io.data as web | |
import pandas.io.sql as sql | |
# Get the data | |
frame = (web.DataReader('FB', # ticker symbol | |
'yahoo', # web service | |
d.datetime(2010, 3, 1), #start date | |
d.datetime.today())) #end date | |
# Wrangle the date field | |
frame = frame.reset_index() | |
frame[['Date']] = frame[['Date']].applymap(lambda x: x.isoformat()) | |
# Write to the database | |
sql.write_frame(frame, 'stockdata', sqlite3.connect("scraperwiki.sqlite")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment