Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
FROM jupyter/datascience-notebook
USER root
# Install libssl-dev
RUN apt-get update
RUN apt-get install libssl-dev -y -q
# Install GNU Octave
RUN apt-get install octave -y -q
server {
listen 80 default_server;
access_log /var/log/nginx/placeholder.log;
root /etc/nginx/placeholder/;
index index.html;
server_name _;
location / {
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
# NOTE: replace datarecipe.com with your domain
server_name datarecipe.com;
return 301 https://$server_name$request_uri;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import pandas_datareader.data as web
import datetime
def set_variables():
ticker_symbols = ['^GSPC', '^DJI', '^IXIC']
start_date = '2000-01-01'
end_date = '2016-06-30'
data_source = 'yahoo'
directory = './'
file_extension = '.csv'
def pull_data():
ticker_symbols, start_date, end_date, data_source, directory, file_extension = set_variables()
start = string_to_date_time(start_date)
end = string_to_date_time(end_date)
for ticker_symbol in ticker_symbols:
df = web.DataReader(ticker_symbol, data_source, start, end)
save_data(df, directory, ticker_symbol, start_date, end_date, file_extension)
def string_to_date_time(s):
sy = int(s[:4])
def save_data(df, directory, ticker_symbol, start_date, end_date, file_extension):
sdt = strip_hyphens(start_date)
edt = strip_hyphens(end_date)
filename = directory + ticker_symbol + '_' + sdt + '-' + edt + file_extension
df.to_csv(filename, index_label="Date")
def strip_hyphens(s):
return s.replace("-", "")
if __name__ == "__main__":
@txthai
txthai / crime-analysis.ipynb
Created August 22, 2016 06:53
San Francisco and Seattle have Different Days of the Week with the Lowest Vehicle Thefts
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.