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
#Cube every number from 1 to 100 | |
#Python map function | |
cubes = map(lambda(x): x*x*x, range(1,100)) | |
#Python list comprehension | |
cubes= [x*x*x for x in range(1,100)] | |
#R sapply function | |
cubes <- sapply(seq(1,100), function(x) x*x*x) |
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
julia> airline_array = readdlm("/Users/randyzwitch/airline/1987.csv", ','); | |
julia> size(airline_array) | |
(1311827,29) | |
julia> typeof(airline_array) | |
Array{Any,2} |
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
julia> airline_array = readdlm("/Users/randyzwitch/airline/1987.csv", ',' , String); | |
julia> size(airline_array) | |
(1311827,29) | |
julia> typeof(airline_array) | |
Array{String,2} |
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
julia> airline_array = readdlm("/Users/randyzwitch/airline/1987.csv", ',' , String); | |
julia> size(airline_array) | |
(1311827,29) | |
julia> typeof(airline_array) | |
Array{String,2} |
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
julia> using DataFrames | |
julia> airline_df = readtable("/Users/randyzwitch/airline/1987.csv.gz"); | |
julia> size(airline_df) | |
(1311826,29) | |
julia> typeof(airline_df) | |
DataFrame (use methods(DataFrame) to see constructors) |
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 collections | |
import nltk | |
#Dictionary from Unix | |
internal_dict = open("/usr/share/dict/words") | |
#Stopwords corpus from NLTK | |
stopwords = nltk.corpus.stopwords.words('english') | |
#Build english_dictionary of prospect words | |
english_dictionary = [] |
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
from mrjob.job import MRJob | |
class MRWordCounter(MRJob): | |
def mapper(self, english_dict, line): | |
english_dict = ['aal', 'aalii', 'aam', 'aani'...'zythum', 'zyzomys', 'zyzzogeton'] | |
for word in english_dict: | |
if word in line: | |
yield word, 1 |
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
python ~/Desktop/mapreduce.py -r emr s3://<s3bucket>/url_unload/0000_part_01 --output-dir=s3://<s3bucket>/url_output --num-ec2-instances=81 |
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
julia> using ODBC | |
julia> ODBC.connect("MySQL") | |
Connection 1 to MySQL successful. |
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
#Amazon Redshift/Postgres connection string | |
Julia> red = advancedconnect("Driver={psqlODBC};ServerName=reporting.XXXXX.us-east-1.redshift.amazonaws.com;Username=XXXX;Password=XXXX;Database=XXXX;Port=XXXX"); | |
Connection 1 to Driver={psqlODBC};ServerName=reporting.XXXXX.us-east-1.redshift.amazonaws.com;Username=XXXX;Password=XXXX;Database=XXXX;Port=XXXX successful. | |
#MySQL connection string | |
julia> my = advancedconnect("Driver={MySQL};user=root;server=localhost;database=airline;") | |
Connection 1 to Driver={MySQL};user=root;server=localhost;database=airline; successful. |