Skip to content

Instantly share code, notes, and snippets.

View rdpapworth's full-sized avatar

Richard Papworth rdpapworth

  • Glasgow, Scotland
View GitHub Profile
@PatWalters
PatWalters / seaborn_scatterplot.ipynb
Last active April 22, 2025 15:02
A Collection of Things I Frequently Forget How To Do With Seaborn Scatterplots
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@northernjamie
northernjamie / SCOTSTAT_Google_Chart_Demo_Full_Code.html
Last active June 9, 2019 20:23
All code needed to generate a basic webpage and google chart using a SPARQL query from scot.stat.gov
<html>
<head>
<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script src='https://code.jquery.com/jquery-3.2.1.min.js'></script>
<script type="text/javascript">
//Set the url of the SPARQL endpoint
var url = 'http://statistics.gov.scot/sparql.json';
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@northernjamie
northernjamie / SPARQLScotDStoreUnionCorrMatrixBlogSplit_2.sparql
Last active March 30, 2017 13:17
SPARQL to get 20 indicators from Scottish datastore for each Council Area to feed a correlation matrix. To go with blog post "Using R and SPARQL to make a correlation matrix". Split query as too many chars for R. Part 2.
PREFIX qb: <http://purl.org/linked-data/cube#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sdmx: <http://purl.org/linked-data/sdmx/2009/concept#>
PREFIX data: <http://statistics.gov.scot/data/>
PREFIX sdmxd: <http://purl.org/linked-data/sdmx/2009/dimension#>
PREFIX mp: <http://statistics.gov.scot/def/measure-properties/>
PREFIX stat: <http://statistics.data.gov.uk/def/statistical-entity#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT ?areaname ?indicatorlabel ?yearname ?value
@jakebathman
jakebathman / icd_regex.md
Last active October 12, 2023 09:31
ICD-9 and ICD-10 code regex

ICD code matching regex

The regex patterns below only help validate when something is not valid ICD-10 or ICD-9. They do not ensure that the code exists. You should consult a list of valid ICD codes for that level of verification.

ICD-10-CM list: https://gist.github.com/jakebathman/063c50cb9772e4bfc864a9e1ff4ccc8d

ICD-9 list: https://gist.github.com/jakebathman/f1ed0d473f12091a708243b0ddf03d82

ICD-10/ICD-9 combined regex

Useful for validating field values that could contain both, and may or may not use decimals

@conormm
conormm / r-to-python-data-wrangling-basics.md
Last active March 25, 2025 00:24
R to Python: Data wrangling with dplyr and pandas

R to python data wrangling snippets

The dplyr package in R makes data wrangling significantly easier. The beauty of dplyr is that, by design, the options available are limited. Specifically, a set of key verbs form the core of the package. Using these verbs you can solve a wide range of data problems effectively in a shorter timeframe. Whilse transitioning to Python I have greatly missed the ease with which I can think through and solve problems using dplyr in R. The purpose of this document is to demonstrate how to execute the key dplyr verbs when manipulating data using Python (with the pandas package).

dplyr is organised around six key verbs:

Here's how to lock or unlock Oracle database user accounts.
SQL> ALTER USER username ACCOUNT LOCK;
SQL> ALTER USER username ACCOUNT UNLOCK;
What is a Standard Operating Procedure (SOP)?
The word ‘Standard Operating Procedure’ shortly known as SOP, probably originated in military or healthcare domains to instill best practices in performing a specific function. SOP is a written document with step-by-step instructions to guide the performer of a process or a function or an activity. The purpose of SOP is not to teach someone how to do a work or to impart a skill, but to imbibe best practices that ensures some sort of standardization in performing a work in a most optimal way. For example, take a SOP ‘Operating a Car’. This SOP will not teach someone how to drive a car, but it does teach the best practices that shall be followed while operating a car such as wearing seat belt, never to move the car while the passengers are within 5 m radius etc.
SOP Classification:
There are three major classifications.
1. SOPs for different verticals such as SOP for Banking, Hospitality, Healthcare, Government, Retail, Supply Chain, Warehousing, Education, Insuranc
@yannabraham
yannabraham / doseResponsePython.ipynb
Last active February 26, 2025 14:29
How to do Dose/Response curve fitting in Python for Drug Discovery
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@docsteveharris
docsteveharris / charlson.score.R
Created November 27, 2014 12:13
Create Charlson Score
score.charlson <- function(data) {
# data is a datatable containing the columns you need
# identify the columns with pmh in the name
require(data.table)
charlson.values <- data[,.(pmhmi, pmhhf, pmhpvd, pmhcvd, pmhdem, pmhcopd, pmhcopd, pmhctd, pmhud, pmhmld, pmhdm, pmhhemi, pmhckd, pmhdmend, pmhtumour, pmhleuk, pmhlymph, pmhsld, pmhmets, pmhaids)]
charlson.matrix <- as.matrix(charlson.values)
# Now I need to convert the NA's to 0 and >0 to 1 in matrix
charlson.matrix <- apply(charlson.matrix, 2, function(x) ifelse(is.na(x), 0, ifelse(x>=1,1, 0)))
# Now create a vector of scores
# Note that the order of the columns selected above *must* match the order of the scores here