Skip to content

Instantly share code, notes, and snippets.

View jtrive84's full-sized avatar

James Triveri jtrive84

View GitHub Profile
@jtrive84
jtrive84 / 2023-big-12-adjacency.csv
Last active October 5, 2024 01:52
2023 Big 12 football results adjacency matrix
Baylor BYU Cincinnati Houston Iowa State Kansas Kansas State Oklahoma Oklahoma State TCU Texas Texas Tech UCF West Virginia
Baylor 0 0 1 0 0 0 0 0 0 0 0 0 1 0
BYU 0 0 1 0 0 0 0 0 0 0 0 1 0 0
Cincinnati 0 0 0 1 0 0 0 0 0 0 0 0 0 0
Houston 1 0 0 0 0 0 0 0 0 0 0 0 0 1
Iowa State 1 1 1 0 0 0 1 0 1 1 0 0 0 0
Kansas 0 1 1 0 1 0 0 1 0 0 0 0 1 0
Kansas State 1 0 0 1 0 1 0 0 0 1 0 1 1 0
Oklahoma 0 1 1 0 1 0 0 0 0 1 1 0 1 1
Oklahoma State 0 1 1 1 0 1 1 1 0 0 0 0 0 1
@jtrive84
jtrive84 / mcmc-introduction.ipynb
Created September 18, 2024 14:50
MCMC Introduction
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jtrive84
jtrive84 / rejection.ipynb
Created September 3, 2024 18:20
Rejection sampling
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jtrive84
jtrive84 / pinmap.py
Created August 21, 2024 14:05
Simple Dash pinmap application
import datetime
import io
import os
import os.path
import sys
import time
import dash
from dash.dependencies import Input, Output
@jtrive84
jtrive84 / nagpd.py
Created August 20, 2024 15:58
Color polygons with NA as white with black borders.
fig, ax = plt.subplots(figsize=(10, 8), tight_layout=True)
ax.set_title("SAM claims by county", fontsize=10)
dd.plot(
ax=ax, column="n", edgecolor="black", linewidth=.50,
cmap="rainbow", alpha=1, legend=True,
legend_kwds={"label": "number of claims", "orientation": "vertical", "shrink": .35},
missing_kwds={"facecolor": "#FFFFFF", "edgecolor": "#000000", "linewidth": .25}
)
ax.axis("off")
plt.show()
@jtrive84
jtrive84 / gbl.py
Created August 20, 2024 14:58
Groupy into list in Pandas
# Create a DataFrame that takes a dataset of 50k State - County - ZIp combinations
# to a table of ~3k reocrds keyed by County, with a list column of zipcodes.
ggck = dfz2c.groupby(["STATE", "FIPS", "County"], as_index=False)["ZIP"].apply(list)
@jtrive84
jtrive84 / bsTheme.R
Created August 14, 2024 18:53
Function to change shiny bootstrap theme
sfThemeSelector = function() {
# --------------------------------------------------------------------------
# Allow dynamic update of bootstrap theme.
# --------------------------------------------------------------------------
div(
div(
selectInput(
"shinytheme-selector", "Select theme:",
c("default", shinythemes:::allThemes()),
@jtrive84
jtrive84 / us-weather-events-2016-2023.csv
Created June 16, 2024 16:11
US weather events: 2016-2023
We can't make this file beautiful and searchable because it's too large.
BEGIN_YEARMONTH,BEGIN_DAY,BEGIN_TIME,END_YEARMONTH,END_DAY,END_TIME,EVENT_ID,STATE,STATE_FIPS,YEAR,MONTH_NAME,EVENT_TYPE,BEGIN_DATE_TIME,CZ_TIMEZONE,END_DATE_TIME,INJURIES_DIRECT,DEATHS_DIRECT,DAMAGE_PROPERTY,DAMAGE_CROPS,MAGNITUDE,MAGNITUDE_TYPE,BEGIN_LAT,BEGIN_LON
201612,27,500,201612,27,900,669700,MASSACHUSETTS,25,2016,December,Strong Wind,12/27/2016 5:00,EST-5,12/27/2016 9:00,0,0,0.10K,0.00K,41,EG,,
201612,27,200,201612,27,600,669703,MASSACHUSETTS,25,2016,December,Strong Wind,12/27/2016 2:00,EST-5,12/27/2016 6:00,0,0,0.10K,0.00K,42,MG,,
201612,27,200,201612,27,700,669707,MASSACHUSETTS,25,2016,December,Strong Wind,12/27/2016 2:00,EST-5,12/27/2016 7:00,0,0,0.10K,0.00K,49,MG,,
201612,27,300,201612,27,700,669708,MASSACHUSETTS,25,2016,December,Strong Wind,12/27/2016 3:00,EST-5,12/27/2016 7:00,0,0,0.10K,0.00K,41,EG,,
201612,18,1400,201612,18,1700,669667,RHODE ISLAND,44,2016,December,Strong Wind,12/18/2016 14:00,EST-5,12/18/2016 17:00,0,0,0.10K,0.00K,46,MG,,
201612,27,200,201612,27,600,669686,MASSACHUSETTS,25,20
@jtrive84
jtrive84 / severity.ipynb
Created June 5, 2024 21:29
Severity Distributions
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jtrive84
jtrive84 / censored-mle.ipynb
Created May 23, 2024 18:48
Censored Maximum Likelihood Estimation
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.