Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get Yahoo!Finance data on ScraperWiki
#!/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
You can’t perform that action at this time.