Skip to content

Instantly share code, notes, and snippets.

View matmoody's full-sized avatar

Matthew matmoody

View GitHub Profile
@matmoody
matmoody / TwitterToSlack.py
Created December 24, 2015 03:58
When specific keyword is mentioned on Twitter, send the tweet to one of your Slack Channels.
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream
import json
import requests
client_key = "TwitterConsumerKey"
client_secret = "TwitterConsumerSecret"
token = "TwitterAppAccessToken"
token_secret = "TwitterAppAccessTokenSecret"
@matmoody
matmoody / live_face.py
Last active September 12, 2017 04:21
Live Face Recognition With Nest Cam And Project Oxford
import json
import requests
class LiveFace():
# Connect To Nest Cam REST Streaming API
def get_stream(self, cam_url):
# Manipulate the response so we can detect if motion was detected
DATA_PREFIX = 'data: '
@matmoody
matmoody / stats.py
Created April 20, 2016 03:52
Overview of Stats
import pandas as pd
from scipy import stats
data = '''Region,Alcohol,Tobacco
North,6.47,4.03
Yorkshire,6.13,3.76
Northeast,6.19,3.77
East Midlands,4.89,3.34
West Midlands,5.63,3.47
East Anglia,4.52,2.92
# Frequency
import collections
testlist = [1, 4, 5, 6, 7, 9, 9, 9]
c = collections.Counter(testlist)
print c
# calculate number of instances in list
import pandas as pd
import scipy.stats as stats
import matplotlib.pyplot as plt
%matplotlib inline
loansData = pd.read_csv('https://github.com/Thinkful-Ed/curric-data-001-data-sets/raw/master/loans/loansData.csv')
loansData.head()
# Remove rows with null values
from scipy import stats
import collections
# Apply collections.Counter() on # open credit lines in Loans data to get counts of observations for each # credit lines
# Load reduced version of Lending Club dataset
loansData = pd.read_csv("https://github.com/Thinkful-Ed/curric-data-001-data-sets/raw/master/loans/loansData.csv")
# Drop null rows
loansData.dropna(inplace=True)
@matmoody
matmoody / linear_regression.py
Created April 26, 2016 02:52
Linear regression analysis
import numpy as np
import pandas as pd
import statsmodels.api as sm
import matplotlib.pyplot as plt
%matplotlib inline
import pandas as pd
loansData = pd.read_csv('https://github.com/Thinkful-Ed/curric-data-001-data-sets/raw/master/loans/loansData.csv')
@matmoody
matmoody / logistic_regression.py
Created April 26, 2016 03:45
Logistic regression analysis
import numpy as np
import pandas as pd
import statsmodels.api as sm
import matplotlib.pyplot as plt
%matplotlib inline
loansData = pd.read_csv('https://github.com/Thinkful-Ed/curric-data-001-data-sets/raw/master/loans/loansData.csv')
# Clean Interest.Rate
loansData['Interest.Rate'] = loansData['Interest.Rate'].map(lambda x: float(x.rstrip('%')))
@matmoody
matmoody / citibike.py
Created April 30, 2016 17:03
Data analysis of CitiBike data. Checking which locations have the most activity on Saturday mornings.import requests
import collections
import matplotlib.pyplot as plt
import pandas as pd
import requests
import sqlite3 as lite
import time
from pandas.io.json import json_normalize
from dateutil.parser import parse
%matplotlib inline
@matmoody
matmoody / temperature.py
Created May 9, 2016 02:50
Request and store the "Maximum Temperature" for 5 cities over 30 day period.
import requests
import sqlite3 as lite
import datetime
api_key = 'API_KEY'
url = 'https://api.forecast.io/forecast/' + api_key
cities = { "Wamego": '39.201941,-96.304998',
"Grinnell": '39.127230,-100.629031',