Skip to content

Instantly share code, notes, and snippets.

View jacobeturpin's full-sized avatar

Jacob Turpin jacobeturpin

View GitHub Profile
@jacobeturpin
jacobeturpin / aws_sso.py
Created December 14, 2020 19:13 — forked from sgtoj/aws_sso.py
AWS SSO Credentials File Updater for AWS SDKs
#!/usr/bin/env python3
import json
import os
import sys
from configparser import ConfigParser
from datetime import datetime
from pathlib import Path
import boto3
@jacobeturpin
jacobeturpin / sample.py
Created November 2, 2020 21:13
Sample and Read CSV using Pandas
"""Sample and read sample into pandas"""
import subprocess
import urllib
import pandas as pd
# City of Raleigh, NC Open Data -- Building Permits (2020-11-02)
URI = "https://opendata.arcgis.com/datasets/bdfad82b15344d37beb28d7f90b6c4be_0.csv"
FULL_FN = "full-dataset.csv"
#!/usr/bin/env python
"""
Simple Click example
"""
import click
@click.command()
@click.option('--km', default=1, help='Number of kilometers')
@click.option('--dec', default=2, help='Number of digits after decimal')
def km_to_mi(km, dec):
@jacobeturpin
jacobeturpin / example-img-bbox.jpg
Last active April 21, 2020 19:46
Example of using AWS Rekognition to identify and draw bounding boxes for faces
example-img-bbox.jpg
@jacobeturpin
jacobeturpin / xor_keras.py
Created January 18, 2020 22:50
XOR Gate in Keras
"""Implementation of XOR Gate Using Keras"""
import numpy as np
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
inputs = np.array([
[0, 0],
[0, 1],
[1, 0],
@jacobeturpin
jacobeturpin / boston.csv
Created October 10, 2019 01:18
Boston Housing Dataset
neighborhood crim zn indus chas nox rooms age dis rad tax ptratio lstat mv
Nahant 0.00632 18 2.31 0 0.538 6.575 65.2 4.09 1 296 15.3 4.98 24
Swampscott 0.02731 0 7.07 0 0.469 6.421 78.9 4.9671 2 242 17.8 9.14 21.6
Swanpscott 0.02729 0 7.07 0 0.469 7.185 61.1 4.9671 2 242 17.8 4.03 34.7
Marblehead 0.03237 0 2.18 0 0.458 6.998 45.8 6.0622 3 222 18.7 2.94 33.4
Marblehead 0.06905 0 2.18 0 0.458 7.147 54.2 6.0622 3 222 18.7 5.33 36.2
Marblehead 0.02985 0 2.18 0 0.458 6.43 58.7 6.0622 3 222 18.7 5.21 28.7
Salem 0.08829 12.5 7.87 0 0.524 6.012 66.6 5.5605 5 311 15.2 12.43 22.9
Salem 0.14455 12.5 7.87 0 0.524 6.172 96.1 5.9505 5 311 15.2 19.15 22.1
Salem 0.21124 12.5 7.87 0 0.524 5.631 100 6.0821 5 311 15.2 29.93 16.5
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
"age";"job";"marital";"education";"default";"balance";"housing";"loan";"contact";"day";"month";"duration";"campaign";"pdays";"previous";"poutcome";"response"
30;"unemployed";"married";"primary";"no";1787;"no";"no";"cellular";19;"oct";79;1;-1;0;"unknown";"no"
33;"services";"married";"secondary";"no";4789;"yes";"yes";"cellular";11;"may";220;1;339;4;"failure";"no"
35;"management";"single";"tertiary";"no";1350;"yes";"no";"cellular";16;"apr";185;1;330;1;"failure";"no"
30;"management";"married";"tertiary";"no";1476;"yes";"yes";"unknown";3;"jun";199;4;-1;0;"unknown";"no"
59;"blue-collar";"married";"secondary";"no";0;"yes";"no";"unknown";5;"may";226;1;-1;0;"unknown";"no"
35;"management";"single";"tertiary";"no";747;"no";"no";"cellular";23;"feb";141;2;176;3;"failure";"no"
36;"self-employed";"married";"tertiary";"no";307;"yes";"no";"cellular";14;"may";341;1;330;2;"other";"no"
39;"technician";"married";"secondary";"no";147;"yes";"no";"cellular";6;"may";151;2;-1;0;"unknown";"no"
41;"entrepreneur";"married";"tertiary";"no
We can make this file beautiful and searchable if this error is corrected: It looks like row 3 should actually have 41 columns, instead of 27. in line 2.
RespondentID,Personal_JavaScalaSpark,Personal_JavaScriptHTMLCSS,Personal_Python,Personal_R,Personal_SAS,Professional_JavaScalaSpark,Professional_JavaScriptHTMLCSS,Professional_Python,Professional_R,Professional_SAS,Industry_JavaScalaSpark,Industry_JavaScriptHTMLCSS,Industry_Python,Industry_R,Industry_SAS,Python_Course_Interest,Foundations_DE_Course_Interest,Analytics_App_Course_Interest,Systems_Analysis_Course_Interest,Courses_Completed,PREDICT400,PREDICT401,PREDICT410,PREDICT411,PREDICT413,PREDICT420,PREDICT422,PREDICT450,PREDICT451,PREDICT452,PREDICT453,PREDICT454,PREDICT455,PREDICT456,PREDICT457,OtherPython,OtherR,OtherSAS,Other,Graduate_Date
5135740122,0,0,0,50,50,0,0,0,25,75,0,0,0,50,50,50,90,51,50,NA,,,,,,,,,,,,,,,,,,,,
5133300037,10,10,50,30,0,25,25,30,20,0,20,25,40,15,0,20,50,90,50,6,PREDICT 400 Math for Modelers (Python),PREDICT 401 Introduction to Statistical Analysis (R),PREDICT 410 Regression and Multivariate Analysis (SAS),PREDICT 411 Generalized Linear Models (SAS),,PREDICT 420 Database Systems