Skip to content

Instantly share code, notes, and snippets.

View jtrive84's full-sized avatar

James Triveri jtrive84

View GitHub Profile
@jtrive84
jtrive84 / dictionary.txt
Created November 27, 2016 04:50
A file to use for various Python tutorials
A
abactinally
Abassieh
Abbottstown
Abe
abevacuation
abiogenesist
ablauts
aboideaus
Aboukir
@jtrive84
jtrive84 / csv.writer_Usage.py
Created November 27, 2016 05:02
Suppress double-spaced output in Python 3 by specifying `lineterminator="\n"` to csv.writer instance.
"""
Suppress double-spaced output in Python 3 by specifying `lineterminator="\n"`
to csv.writer instance.
"""
import csv
fsrc_pth = "src_pth"
fdst_pth = "dst_pth"
with open(fdst_pth, 'w') as f1:
@jtrive84
jtrive84 / ticker_data.csv
Last active November 28, 2016 01:59
A sample file for `An Introduction to sqlite3` gist.
DATE TICKER CLOSE
20161125 GE 31.440001
20161123 GE 31.34
20161122 GE 31.18
20161121 GE 30.870001
20161118 GE 30.67
20161117 GE 30.790001
20161116 GE 30.74
20161115 GE 30.75
20161114 GE 30.51
@jtrive84
jtrive84 / Python_Higher_Order_Functions.md
Created November 28, 2016 02:21
Introduction to Python's higher order functions and typical usage scenarios.
@jtrive84
jtrive84 / Python_Data_Structures_and_Iteration.md
Created November 28, 2016 02:24
An introduction to common Python data structures and iteration.

Python Data Structures and Iteration

The first part of this introduction will discuss two very useful functions: enumerate and zip:

@jtrive84
jtrive84 / generate_dircolors.txt
Created December 6, 2016 02:45
Command to generate user DIR_COLORS file
cd && dircolors -p > .dircolors
@jtrive84
jtrive84 / Fire_Claims.csv
Created December 24, 2016 02:16
Sample Fire Claims table for DeMorgan's Laws blog post
CLAIM_ID EXPOSURE_ID STATE BLD_VALUE BLD_AGE CLAIM_AMT
695433 POL0004653 IL 1337609 7 1337609
621498 POL0002262 TN 509477 35 509477
818474 POL0009754 CT 953878 38 953878
785806 POL0002506 OR 106964 55 106964
799534 POL0002989 IL 469804 108 469804
729094 POL0005797 TN 894399 35 100000
610517 POL0005640 CT 532730 60 532730
888963 POL0005099 OR 1255253 34 1255253
607409 POL0003997 IL 688008 64 100000
@jtrive84
jtrive84 / is_prime.py
Created January 22, 2017 04:32
Function to determine if passed integer is prime
import math
def is_prime(n):
"""Determine if `n` is prime."""
if (n%2==0 or n%3==0): return(False)
threshold = math.floor(math.sqrt(n))
# all primes are of the form 6k+/-1 =>
plus_tst = any(n%i for i in
(6*k+1 for k in
@jtrive84
jtrive84 / numpyIO.py
Created February 19, 2017 23:48
Reading dataset with genfromtxt (numpy)
import numpy as np
fpath = "challenger.csv"
# Setting dtype to `None` forces genfromtxt to determine
# the datatypes of each column =>
res = np.genfromtxt(fname=fpath,
dtype=None,
delimiter=",",
autostrip=True,
@jtrive84
jtrive84 / R_Packaging.ipynb
Created March 21, 2017 23:28
Creating R packages with devtools and roxygen2
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.