Skip to content

Instantly share code, notes, and snippets.

View jeffmylife's full-sized avatar
🌊
back to learning

Jeffrey Lemoine jeffmylife

🌊
back to learning
View GitHub Profile
@jeffmylife
jeffmylife / Makefile
Created May 20, 2023 23:14
Makefile with yaml configuration for AWS Batch Job project. Defines variables in Makefile based on a target's dependencies.
.phony: all
all: push
# configuration setup
PROJECT_FILE_NAME=project.yml
CONFIG := python3 -c "import yaml; import json; from pathlib import Path; print(json.dumps(yaml.safe_load(Path(\"$(PROJECT_FILE_NAME)\").read_text())))"
OS := $(shell python3 -c "import platform; print(platform.system())")
# defaults
@jeffmylife
jeffmylife / equity_sampler.py
Created January 4, 2024 21:20
Sampling without replacement to acheive the most balanced representation across skewed distributions
import pandas as pd
def sample_dataframe(df, date_column, N):
"""
Samples a pandas DataFrame to achieve a balanced representation across different date groups.
This function ensures that smaller date groups (those with counts less than an average size)
are fully represented in the sample. Larger date groups are sampled uniformly to contribute
towards a total sample size of N. If the initial sampling process results in a total sample size