This file contains 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 score_calculation(weights, school, district): | |
''' | |
district is a list of census blocks which we are including on the district | |
school is a specific school id | |
the weights normalize the scores taking into account their relative importance | |
''' | |
# population of district and minority population from global DataFrame block_data | |
pop = block_data['HS_POP'].loc[district].sum() | |
minority_pop = block_data['MINORITY'].loc[district].sum() |
This file contains 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
library(rvest) | |
library(tidyRSS) | |
library(tidyverse) | |
library(stringr) | |
# https://www.cjr.org/analysis/as-election-looms-a-network-of-mysterious-pink-slime-local-news-outlets-nearly-triples-in-size.php | |
pinkslimesites <- read.csv("pinkslimesites.csv", stringsAsFactors = F) | |
all_pinkslimesites <- pinkslimesites %>% | |
mutate(Rss = paste0(Domain,"/stories.rss")) |
This file contains 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
library(tidyverse) | |
library(rtweet) | |
library(twinetverse) | |
JimJordan <- search_tweets2("https://twitter.com/Jim_Jordan/status/1257813096707641346", n = 15000, include_rts = T) | |
glimpse(JimJordan) | |
JimJordan <- JimJordan %>% | |
mutate(maga_label = str_detect(description, "MAGA")) %>% |
This file contains 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
library(data.table) | |
library(dplyr) | |
library(R.utils) | |
# JUST MASS | |
mass <- gunzip("arcos-ma-statewide-itemized.tsv.gz") | |
mass_opioids <- fread(file = 'arcos-ma-statewide-itemized.tsv') | |
glimpse(mass_opioids) # 2,574,240 observations | |
summary(mass_opioids) |
This file contains 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
library(tidyverse) | |
library(leaflet) | |
library(geojsonio) | |
library(htmlwidgets) | |
library(htmltools) | |
nycmarkers <- read.csv("nycmarkers.csv", stringsAsFactors=F) # with "lat", "lon" and "string" columns | |
nycshapefile <- geojsonio::geojson_read("nycshapefile.geojson", what = "sp") |
This file contains 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
library(dplyr) | |
library(tidyverse) | |
library(tidytext) | |
library(plotly) | |
library(stringr) | |
# Pull in spreadsheet | |
df <- read.csv("fbads.csv", header=TRUE, stringsAsFactors = FALSE) | |
df$date <- as.Date(df$created_at) # Add date column | |
df %>% glimpse() |
This file contains 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 fs = require("fs"); | |
var table = read_table("data/hurdat2-1851-2017-050118.txt", ","); | |
var curr_obj, | |
curr_entry_count; | |
var data = [], | |
geojson = { | |
"type": "FeatureCollection", |
This file contains 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
library(tidyverse) | |
library(ggplot2) | |
dataset <- read.csv("winemag-data.csv", | |
header=TRUE, stringsAsFactors=FALSE) | |
dataset %>% glimpse(102) | |
# Quick view and descriptive stats | |
min(dataset$points) | |
max(dataset$points) |
This file contains 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
library(ggplot2) | |
library(tidyverse) | |
library(fiftystater) | |
mapdata <- read.csv("state-medal-count.csv", header=TRUE, stringsAsFactors=FALSE) | |
mapdata %>% glimpse() | |
data("fifty_states") | |
ggplot() + geom_polygon( data=fifty_states, aes(x=long, y=lat, group = group),color="white", fill="grey10" ) |
This file contains 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 | |
import requests | |
import threading | |
import os | |
import sys | |
from Queue import Queue | |
from bs4 import BeautifulSoup as bs | |
# Globals | |
q = Queue() |
NewerOlder