brew install libspatialite
geojson-to-sqlite toxmap.db hotspots hotspot_perimeters_for_data_store.geojson --spatialite
datasette toxmap.db --load-extension=spatialite
import os | |
import csv | |
from dateutil.parser import parse | |
from slack import WebClient | |
from slack.errors import SlackApiError | |
slack_token = os.environ["SLACK_API_TOKEN"] | |
client = WebClient(token=slack_token) | |
march_27 = parse('3/27/2022').date() |
# create dataframe of all shootings by gender | |
all_police_shootings_by_gender <- fatal_police_shootings %>% | |
group_by(gender) %>% | |
summarise(count=n()) %>% | |
arrange(desc(count)) | |
# create separate dataframes for each gender | |
all_shootings_men <- all_police_shootings_by_gender %>% | |
filter(gender == 'M') |
Sample template for basic filtering, mutate and group_by with count | |
```{r} | |
my_result <- original_data %>% | |
filter(some_column == "some value") %>% | |
mutate(some_column=str_to_title(some_column)) %>% | |
group_by(some_column) %>% | |
summarise(new_aggregate = n()) %>% | |
arrange(desc(new_aggregate)) |
F3XNC00694323WINREDPO BOX 9891ARLINGTONVA22219MYP20222021010120210630OttenhoffBenjamin20210728506.45258275844.90258276351.35258275634.48716.870.00105821.00228991233.65826.00228992059.650.0098300.00229090359.650.000.000.000.0029185485.250.000.000.000.00258275844.90258275844.900.000.00615.58615.580.00229061108.650.000.000.000.0029185485.250.000.0029185485.2528425.000.000.000.000.00258275634.48258275634.48229090359.6529185485.25199904874.40615.580.00615.58506.452021258275844.90258276351.35258275634.48716.87228991233.65826.00228992059.650.0098300.00229090359.650.000.000.000.0029185485.250.000.000.000.00258275844.90258275844.900.000.00615.58615.580.00229061108.650.000.000.000.0029185485.250.000.0029185485.2528425.000.000.000.000.00258275634.48258275634.48229090359.6529185485.25199904874.40615.580.00615.58 |
allegany_sums_all <- allegany_athletics %>% | |
group_by(county, year) %>% | |
summarise(boys_total = sum(boys_participants), girls_total = sum(girls_participants)) %>% | |
select(county, year, boys_total, girls_total) | |
allegany_sums_without_cau <- allegany_athletics %>% | |
filter(is.na(type)) %>% | |
group_by(county, year) %>% | |
summarise(boys_without_cs = sum(boys_participants), girls_without_cs = sum(girls_participants)) %>% | |
select(county, year, boys_without_cs, girls_without_cs) |
html <- read_html("https://merrill.umd.edu/about/faculty-and-staff") | |
# get faculty/staff names | |
names <- html %>% html_nodes(".card-title") %>% html_text() | |
length(faculty_staff) | |
faculty_staff[1] | |
# get titles |
my_data %>% | |
mutate( | |
category = case_when( | |
amount < 10000 ~ 'under_10k', | |
amount < 50000 ~ '10k_50k', | |
amount < 100000 ~ '50k_100k', | |
amount < 500000 ~ '100k_500k', | |
amount < 1000000 ~ '500k_1m', | |
amount > 1000000 ~ '1m_plus' | |
) |
library(tidyverse) | |
library(stringr) | |
library(fs) | |
results <- data.frame() | |
years <- c('2021','2020') | |
for (year in years) { | |
data_dir <- str_c("/Users/dwillis/code/wbb/fiba/", year) |
import csv | |
source = 'greene.txt' | |
offices = ['PRESIDENT AND VICE PRESIDENT', 'LIEUTENANT GOVERNOR FED-INTRA', 'GOVERNOR FED-INTRA', 'US Representative, District 34', 'SECRETARY OF STATE FED-INTRA', 'STATE TREASURER FED-INTRA', | |
'ATTORNEY GENERAL FED-INTRA', 'US REPRESENTATIVE - DISTRICT 7 FED-INTRA', 'STATE REPRESENTATIVE - 135 DST 135', 'COMMISSIONER - DISTRICT 2 DST 2', 'SHERIFF GREENE', 'ASSESSOR GREENE', | |
'TREASURER GREENE', 'PUBLIC ADMINISTRATOR GREENE', 'Constitutional Amendment No. 1 FED-INTRA', 'Constitutional Amendment No. 3 FED-INTRA', 'Supreme Court Judge - Patricia Breckenridge GREENE', | |
'Court of Appeals Judge, Southern District - Gary W.', '31st Judicial Circuit Div. No. 2 - Jones GREENE', '31st Judicial Circuit Div. No. 6 - Borthwick GREENE', 'Associate - 31st Circuit Div. No. 23 - Hosmer GREENE', | |
'Associate - 31st Circuit Div. No. 26 - Carrier GREENE', 'STATE REPRESENTATIVE - 134 DST 134', 'STATE REPRESENTATIVE - 132 DST 132', 'COMMISSIONER - DISTRICT 1 DST 1', 'STATE REPRESENTATIVE - 133 DST 133 |