Skip to content

Instantly share code, notes, and snippets.

@dast1
dast1 / q3
Created February 3, 2018 22:11
Simple Random Sampling vs Thompson Algorithm
# Question 3
# Import the libraries
import numpy as np
import pandas as pd
# Recreate the dataset function
def recreate_dataset(set_size, conversion_ratios):
import random
@dast1
dast1 / text_analyzer.py
Created February 3, 2018 22:10
Text Analyzer
# Text Analyzer
# Import text & break up into words
raw_text = open('test.txt').read().lower()
# Clean up special words: replacing false sentence stop from exception words
def cleanup_special_words(text):
# Since sentences ussually end with a [.?!], we need to create a dictionary of
# exception words that contain these characters
exceptions = {'u.s.':'u*s*',
@dast1
dast1 / yahoo_batch_stock_price_downloader(multi-core).py
Created January 7, 2018 23:22
This is a multiprocessing enabled batch Yahoo Stock Price downloader.
# Choose Ticker Universe (example: Run russell3000.py)
exec(open("russell3000(v.1.0).py").read())
# Import Libraries
import datetime as dt
import pandas_datareader as web
import multiprocessing as multi
import numpy as np
import math
@dast1
dast1 / Russell3000_v1.py
Last active October 21, 2023 12:34
Scrapes the Russell 3000 Membership List (official source in .pdf) and builds Symbol List
# Build Russell 3000 List
# Import libraries
import urllib.request
import datetime
# Download Russell 3000 to local repository
f_path = "/Russell3000/Membership Lists/"
f_name = f_path + "Russell3000 " + datetime.date.today().strftime("(%b %d, %Y)") + ".pdf"
def download_file(url):