Skip to content

Instantly share code, notes, and snippets.

View aarong1's full-sized avatar
🌴
On vacation

Aaron Gorman aarong1

🌴
On vacation
View GitHub Profile
@aarong1
aarong1 / all_na_in_each_factor.py
Created February 14, 2024 09:47
Simple one-liner to test for if all the entries of the factor (group by) column are present and non NULL/non NA
import pandas
projects_df.set_index('id').isna().groupby(level=0).sum()['ServiceAccount'].sum()
@aarong1
aarong1 / strings.py
Created September 15, 2023 00:27
the appropriate way to call string functions sequentially on a character column
pd_df['column'].str.lower().str.strip()
@aarong1
aarong1 / airflow_install.sh
Last active August 5, 2023 20:57
the correct (after much trial and error ) way of install apache airflow on macOS
#https://airflow.apache.org/docs/apache-airflow/stable/installation/installing-from-pypi.html
python -m venv .venv
source .venv/bin/activate
# AIRFLOW_VERSION=2.6.3
export AIRFLOW_HOME=~/airflow
sudo pip3 install "apache-airflow[celery]==2.6.3" --constraint "https://raw.githubusercontent.com/apache/airflow/constraints-2.6.3/constraints-3.10.txt"
@aarong1
aarong1 / read_file.py
Created July 6, 2023 15:40
easy read file wrapping the context handler and closing the connection
def read_file(filename):
with open(filename, 'r') as f:
content = f.read()
f.close()
return content
@aarong1
aarong1 / common_cool_bash_commands.sh
Created May 21, 2023 16:20
interesting bash commands ran from the command line
echo "Logfile started: $(date +'%D %T'$" > log.txt
import logging
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
logging.info(f'This is a logging message with an {fstring}')
@aarong1
aarong1 / load_yaml.py
Last active July 17, 2023 15:10
load a yaml file. A human readable file type usually used for configurations
import yaml
yaml.load(open(<path_to_yaml_config>, 'r'), Loader=yaml.SafeLoader)
# convert json to yaml and back again.
import json
with open('config.json', 'r') as file:
configuration = json.load(file)
@aarong1
aarong1 / README.md
Created February 7, 2022 19:27 — forked from lopspower/README.md
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@aarong1
aarong1 / plotlyR_example.R
Created January 30, 2022 21:18
Example of using the naive plot_ly method
library(plotly)
fig <- plot_ly(
type = 'scatter',
mode='markers',
y=rep(5, 40),
marker=list(
size=seq(0, 39),
color=seq(0, 39),
colorbar=list(
@aarong1
aarong1 / web_scrape.py
Created January 19, 2022 22:42
python web scraper urllib.requests
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 15 16:36:30 2021
@author: dsuser
"""
import os
print(os.getcwd())
os.chdir("C:/Users/Public/Desktop/TraceData/hscni-analytics-data/R/risk_assess")