Skip to content

Instantly share code, notes, and snippets.

View seanjtaylor's full-sized avatar

Sean J. Taylor seanjtaylor

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@seanjtaylor
seanjtaylor / gist:568141f04a16d518be24
Created February 11, 2015 01:46
Reshaping a Pandas dataframe into a sparse matrix
import pandas as pd
import scipy.sparse as sps
df = pd.DataFrame({'tag1': ['sean', 'udi', 'bogdan'], 'tag2': ['sean', 'udi', 'udi'], 'freq': [1,2,3]})
# tag1 -> rows, tag2 -> columns
df.set_index(['tag1', 'tag2'], inplace=True)
mat = sps.coo_matrix((df.freq, (df.index.labels[0], df.index.labels[1])))
print(mat.todense())
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@seanjtaylor
seanjtaylor / benfords_law.R
Created November 6, 2020 06:46
Benford's Law
library(tidyverse)
library(rvest)
doc <- read_html("https://county.milwaukee.gov/EN/County-Clerk/Off-Nav/Election-Results/Election-Results-Fall-2020")
doc %>%
html_nodes('table') %>%
.[[4]] %>%
html_table() %>%
tail(-1) %>%
mutate(ward = 1:n(),
biden = stringr::str_sub(X3, 1, 1),
This file has been truncated, but you can view the full file.
* installing *source* package 'prophet' ...
** using staged installation
** libs
*** arch - i386
d:/Compiler/rtools40/mingw32/bin/g++ -std=gnu++14 -I"D:/RCompile/recent/R-4.0.2/include" -DNDEBUG -I"../inst/include" -I"d:/RCompile/CRANpkg/lib/4.0/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -DRCPP_PARALLEL_USE_TBB=1 -I'd:/RCompile/CRANpkg/lib/4.0/BH/include' -I'd:/RCompile/CRANpkg/lib/4.0/Rcpp/include' -I'd:/RCompile/CRANpkg/lib/4.0/RcppEigen/include' -I'd:/RCompile/CRANpkg/lib/4.0/rstan/include' -I'd:/RCompile/CRANpkg/lib/4.0/StanHeaders/include' -I"d:/Compiler/gcc-4.9.3/local330/include" -DRCPP_PARALLEL_USE_TBB=1 -I"d:/RCompile/CRANpkg/lib/4.0/RcppParallel/include" -D_REENTRANT -DSTAN_THREADS -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c RcppExports.cpp -o RcppExports.o
In file included from d:/RCompile/CRANpkg/lib/4.0/RcppEigen/include/Eigen/Core:392,
from d:/RCompile/CRANpkg/lib/4.0/RcppEigen/include/Eigen/Dense:1,
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.