Skip to content

Instantly share code, notes, and snippets.

library(tidyverse)
train_raw <- read_csv("/Users/aaron/Downloads/train 2.csv")
library(lubridate)
train_raw %>%
mutate(
age_upon_outcome = as.period(as.Date(datetime) - date_of_birth),
age_upon_outcome = time_length(age_upon_outcome, unit = "weeks")
) %>%
@rankam
rankam / cohort.py
Last active October 25, 2020 11:30
import pandas as pd
import datetime
def diff_month(d1, d2):
return (d1.year - d2.year) * 12 + d1.month - d2.month
# add the location to your csv
data = pd.read_csv(csv_file)
# change values in by=[] to the 1) account_id/name, 2) open date 3) close date to whatever you've named the
# add code
__label__sauce __label__cheese How much does potato starch affect a cheese sauce recipe?
__label__food-safety __label__acidity Dangerous pathogens capable of growing in acidic environments
__label__cast-iron __label__stove How do I cover up the white spots on my cast iron stove?
__label__restaurant Michelin Three Star Restaurant; but if the chef is not there
__label__knife-skills __label__dicing Without knife skills, how can I quickly and accurately dice vegetables?
__label__storage-method __label__equipment __label__bread What's the purpose of a bread box?
__label__baking __label__food-safety __label__substitutions __label__peanuts how to seperate peanut oil from roasted peanuts at home?
__label__chocolate American equivalent for British chocolate terms
__label__baking __label__oven __label__convection Fan bake vs bake
__label__sauce __label__storage-lifetime __label__acidity __label__mayonnaise Regulation and balancing of readymade packed mayonnaise and other sauces
@rankam
rankam / word_count.py
Last active April 6, 2020 13:57
word_count.py
import pandas as pd
keywords = ['nhs', 'love']
words = ['i love football', 'nhs is awful', 'what is this', 'i love nhs because nhs is love', 'who are you']
df = pd.DataFrame(words, columns=['words'])
all_results = []
for words in df.words:
tmp_results = []
for keyword in keywords:
keyword_count = 0
@rankam
rankam / helpers.date.js
Created December 8, 2016 23:12 — forked from Gaurav0/helpers.date.js
Routing Example
import Ember from 'ember';
export function date(params) {
return moment(date[0]).format('MMM Do');;
}
export default Ember.Helper.helper(date);
This file has been truncated, but you can view the full file.
<?xml version="1.0" encoding="utf-16"?>
<VisualDefinition xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Html>&lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"&gt;
&lt;div&gt;
&lt;a id="left-menu" data-open="true" class="btn btn-default mobileMenu"&gt;
&lt;i class="glyphicon glyphicon-list"&gt;&lt;/i&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;div id='chart'&gt;
{
"cells": [
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": false
},
"outputs": [
{
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.