Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 geojson | |
| import parse as p #shorter name for our parse program | |
| def create_map(data_file): | |
| """csv file -> parse -> creates a geojson - javascript object notation - file """ | |
| # define the type of geoJSON that we're creating | |
| geo_map = {"type": "FeatureCollection"} #GeoJSON specification |
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 csv | |
| MY_FILE = "../data/sample_sfpd_incident_all.csv" | |
| #../ means go up one directory | |
| #all caps means a constant variable | |
| def parse(raw_file, delimiter): | |
| """ csv file -> JSON-like object""" | |
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 collections import Counter #collections is a standard library, Counter is capitalized | |
| import csv | |
| import matplotlib.pyplot as plt #renames the pyplot function from third party library | |
| import numpy.numarray as na # best practices: import in alphabetical order | |
| MY_FILE = "../data/sample_sfpd_incident_all.csv" | |
| def parse(raw_file, delimiter): | |
| """ csv file -> JSON-like object""" |
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
| #Rosalind problem 1 | |
| def ACGT_count(sequence): | |
| ''' | |
| (str) -> (int, int, int, int) | |
| Count the number of A, C, G and T in a string. | |
| >>>ACGT_count('ATGCTTCAGAAAGGTCTTACG') | |
| 6 4 5 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
| def transcribe(s): | |
| '''given a DNA string, replace each T with a U and write it back out as RNA | |
| (str) -> (str) | |
| >>>transcribe('ATGCCCGGGTTTAAA') | |
| AUGCCCGGGUUUAAA | |
| ''' |
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 complementary(s): | |
| ''' | |
| (str) -> (str) | |
| Returns the reverse complementary strand of s. | |
| >>>complementary('AAACCCTTTGGG') | |
| CCCAAAGGGTTT | |
| ''' |
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 fizzbuzz(last): | |
| list = range(1, (last + 1)) | |
| for num in list: | |
| if num % 15 == 0: | |
| num = "fizzbuzz" | |
| print str(num) | |
| elif num % 3 == 0: | |
| num = "fizz" |
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
| __author__= 'szeitlin' | |
| import pandas | |
| import vincent | |
| MYFILE = "UNdata_Export_20140325_115007094.csv" | |
| #read in a csv file | |
| mydata = pandas.read_csv(MYFILE) |
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
| __author__ = 'szeitlin' | |
| def return_duplicates(nums): | |
| """ | |
| (list) -> (sub-list) | |
| look for duplicates and just return those | |
| >>> return_duplicates([5,5,2,3,4,5,2]) | |
| [2, 2, 5, 5, 5] |
OlderNewer