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, sklearn | |
import pandas as pd | |
import os | |
# os.chdir('./Ranger Data/data') | |
def csv2dataframe(fileobj): | |
"""Returns csv file as a pandas dataframe""" | |
with open(fileobj, 'r') as f: | |
return pd.read_csv(f, header=0) |
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 | |
import sklearn | |
import pandas as pd |
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
def csv2dataframe(fileobj): | |
"""Returns csv file as a pandas dataframe""" | |
with open(fileobj, 'r') as f: | |
return pd.read_csv(f, header=0) | |
# read all csv files to DataFrame objects and append to list then concatenate all dfs in list into one 'super_df' | |
df_list = [csv2dataframe(file) for file in os.listdir(os.getcwd()) if file.endswith('.csv')] | |
ranger_classes = [1, 3, 4, 5, 6, 7, 8, 9, 10, 11] | |
super_df = pd.concat(df_list) |
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
def useless_columns(df): | |
"""Returns list of columns with less than 30 not null values""" | |
columns = [] | |
for col in df.columns: | |
# isnull returns a list-like object with True is an element in the column is NaN and False if element has value | |
null_list = pd.isnull(df[col]) | |
real_values = len([i for i in null_list if i != True]) | |
if real_values < 30: | |
columns.append(col) | |
return columns |
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
function flatten(array) { | |
var output = []; | |
// iterate through all items in argument array | |
for (var j = 0; j < array.length; j++) { | |
var value = array[j]; | |
// base case: value is not an array, so just push to output | |
if (!Array.isArray(value)) { | |
output.push(value); | |
} else { | |
// recursive case: if value is an array, flatten it to a 1D array. |
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
function each(collection, callback) { | |
if (Array.isArray(collection)) { | |
for (var i = 0; i < collection.length; i++) { | |
callback(collection[i]); | |
} | |
} else { | |
for (var j in collection) { | |
callback(collection[j]); | |
} | |
} |
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
var gulp = require('gulp'); | |
var browserSync = require('browser-sync') | |
.create(); | |
//var sass = require('gulp-sass'); | |
// Static Server + watching scss/html files | |
gulp.task('serve', function () { | |
browserSync.init({ | |
server: "./" |
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
// implementation of quicksort | |
var quickSort = function (arr) { | |
if (arr.length === 0) { | |
return []; | |
} | |
var left = []; | |
var right = []; | |
var pivot = arr[arr.length - 1]; // use right most value as pivot |
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
var quickSort = function (arr) { | |
if (arr.length === 0) { | |
return []; | |
} | |
var left = []; | |
var right = []; | |
var pivot = arr[arr.length - 1]; // use right most value as pivot | |
_.each(arr.slice(0, arr.length - 1), function (each) { |
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
var http = require('http'); | |
var bl = require('bl'); | |
// file path is from enviroment variable passed in through CLI | |
var url = process.argv[2]; | |
var consolidated = ''; | |
var callback = function(data) { | |
consolidated += data; |
OlderNewer