Lecture 1: Introduction to Research — [📝Lecture Notebooks] [
Lecture 2: Introduction to Python — [📝Lecture Notebooks] [
Lecture 3: Introduction to NumPy — [📝Lecture Notebooks] [
Lecture 4: Introduction to pandas — [📝Lecture Notebooks] [
Lecture 5: Plotting Data — [📝Lecture Notebooks] [[
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
from urllib.parse import urlsplit | |
import advertools as adv | |
sites = [ | |
'https://www.who.int', | |
'https://www.nytimes.com', | |
'https://www.washingtonpost.com', | |
] |
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
# Import packages | |
import yfinance as yf | |
import pandas as pd | |
# Read and print the stock tickers that make up S&P500 | |
tickers = pd.read_html( | |
'https://en.wikipedia.org/wiki/List_of_S%26P_500_companies')[0] | |
print(tickers.head()) | |
# Get the data for this tickers from yahoo finance |
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
import pandas as pd | |
import numpy as np | |
from bs4 import BeautifulSoup as soup | |
from urllib.request import Request, urlopen | |
pd.set_option('display.max_colwidth', 25) | |
# Input | |
symbol = input('Enter a ticker: ') | |
print ('Getting data for ' + symbol + '...\n') |
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
import numpy as np | |
from statsmodels.regression.linear_model import OLS | |
from statsmodels.tsa.tsatools import lagmat, add_trend | |
from statsmodels.tsa.adfvalues import mackinnonp | |
def adf(ts, maxlag=1): | |
""" | |
Augmented Dickey-Fuller unit root test | |
""" | |
# make sure we are working with an array, convert if necessary |
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
from flask import Flask, render_template | |
from flask_bootstrap import Bootstrap | |
from flask_wtf import Form | |
from wtforms.fields import DateField | |
app = Flask(__name__) | |
app.config['SECRET_KEY'] = 'secret' | |
Bootstrap(app) |
type below:
brew update
brew install redis
To have launchd start redis now and restart at login:
brew services start redis
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
# Terminal Cheat Sheet | |
pwd # print working directory | |
ls # list files in directory | |
cd # change directory | |
~ # home directory | |
.. # up one directory | |
- # previous working directory | |
help # get help | |
-h # get help |