This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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) |
NewerOlder