Skip to content

Instantly share code, notes, and snippets.

Avatar

Joseph Allen joseph-allen

View GitHub Profile
@joseph-allen
joseph-allen / times.js
Last active Aug 9, 2016
converts TV times to useful times
View times.js
fs = require('fs');
moment = require('moment');
var dates = []
fs.readFile('times.js', 'utf8', function (err,data) {
if (err) {
return console.log(err);
}
View no-clone-deep.js
/**
* @fileoverview Rule to flag use of _.cloneDeep
* @author Joseph Allen
*/
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
module.exports = function(context) {
View gist:df15cbba395114a2dd9db63f25e84629
{
"cells": [
{
"cell_type": "code",
"execution_count": 518,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
View setup github issues labels.sh
#!/bin/bash
echo -n "GitHub User: "
read USER
echo -n "GitHub Password: "
read -s PASS
echo ""
echo -n "GitHub Repo (e.g. foo/bar): "
View Dataframe_permuter.py
import pandas as pd
import sys
import itertools
def permute(df):
columns = [df[column] for column in list(df)]
uniq_columns = [columns[x].unique() for x in range(0, len(columns))]
return pd.DataFrame(list(itertools.product(*uniq_columns)),
@joseph-allen
joseph-allen / gist:f50306ba76d5c539feeb281384702a80
Created Sep 28, 2017
exporting jupyter notebook without input
View gist:f50306ba76d5c539feeb281384702a80
jupyter nbconvert --to pdf Report.ipynb --TemplateExporter.exclude_input=True
View fixture_test_structure.py
@pytest.fixture(params=[('input', 'expected')])
def get_input(request):
return request.param
@pytest.fixture
def get_function_result(get_input):
return test_function(get_input[0])
View gist:9e89e627915e6ea291cf06d3af928299
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
from sklearn.tree import DecisionTreeClassifier
def plot_histograms(df, variables, n_rows, n_cols):
fig = plt.figure(figsize=(16, 12))
for i, var_name in enumerate(variables):
ax = fig.add_subplot(n_rows, n_cols, i+1)
@joseph-allen
joseph-allen / useful imports
Created Dec 29, 2017
Useful imports for a jupyter investigation
View useful imports
# Ignore warnings
import warnings
warnings.filterwarnings('ignore')
# Handle table-like data and matrices
import numpy as np
import pandas as pd
# Modelling Algorithms
from sklearn.tree import DecisionTreeClassifier
@joseph-allen
joseph-allen / outlier_detection
Created Dec 29, 2017
Tukey method outlier detection
View outlier_detection
import numpy as np
from collections import Counter
def detect_outliers(df, n, features):
"""
Takes a dataframe df of features and returns a list of the indices
corresponding to the observations containing more than n outliers according
to the Tukey method.
"""
You can’t perform that action at this time.