Skip to content

Instantly share code, notes, and snippets.

View discdiver's full-sized avatar

Jeff Hale discdiver

View GitHub Profile
@discdiver
discdiver / git_branch.md
Last active May 2, 2020 12:35
Basic Git Workflow with Local Branches and Pushing Directly to the Master Branch

Basic Git Branching Workflow

There are many potential Git workflows. The following is a basic workflow for someone working alone, using different local branches, pushing directly the master remote branch.

To make a new branch locally:

  1. git checkout -b my_branch_name - create and move to a new branch
  2. Do work.
  3. git status - check on things.
  4. git add . - stage changes to be committed.
  5. git commit -m "my_commit-message" - commit changes.
import pandas as pd
import numpy as np
import plotly.offline as py
import plotly.graph_objs as go
import json
py.init_notebook_mode(connected=False)
izip = zip
@discdiver
discdiver / causality-python-packages.md
Last active September 29, 2020 15:53
Python libraries for causal inference

Name, Purpose, and GitHub Stars as of 9/28/20

  • DoWhy - making causal inference easy (Microsoft) - 2,258
  • CausalML - suite of uplift modeling and causal inference methods using machine learning algorithms based on recent research (Uber) - 1,322
  • causal impact - implementation of Google's model with all functionalities fully ported and tested - 312
  • cfrnet - counterfactual regression (doesn't appear to be actively developed) - 135
  • Causality - tools for causal analysis using observational (rather than experimental) datasets (doesn't appear to be actively developed) - 804
  • Causal Discovery Toolbox - causal inference in graphs and pairwise settings - 333
@discdiver
discdiver / git_fork_clone_sync.md
Last active October 1, 2021 20:47
Forking, Cloning, and Syncing with Git and GitHub

How to fork, clone, and sync from a GitHub repository.

  1. From the GitHub GUI: Fork the repository (click fork).
  2. From your forked repository in the GitHub GUI: Click clone and copy the URL.
  3. From the command line: in the directory you want to put your local copy of the repository, type git status to make sure you are not already in a local git repository folder.
  4. Then type git clone insert_the_url_from_above
  5. cd into the cloned repository.
  6. git remote -v to see the tracking versions. You should see origin, but no upstream.
  7. From the original repository in the GitHub GUI (not yours): Click clone and copy the URL.
  8. git remote add upstream insert_url_of_original_repository_from_the_step_above - the URL to insert will NOT have your username in it.
@discdiver
discdiver / vscode-setup.md
Last active December 5, 2021 14:39
How to set up Visual Studio Code
  1. See if you have Visual Studio Code installed by looking in your apps. If you don't, have it installed, install it from here
  2. Configure Visual Studio Code to be your editor for git. From the command line run: git config --global core.editor "code -w"
  3. Mac users: Set Visual Studio Code to open with code from the command line outside VS Code. Instructions here, press command + shift + p
  4. Select Shell Command: Install 'code' command in PATH. Windows users should have the functionality automatically.
  5. Install the Python extension for Visual Studio Code. Click on the Extensions icon in the left side bar and search for Python. Select and install it.
  6. Make black your autoformatter. In the top menu bar go Code -> Preferences -> Settings and type black. Select Under Python > Formating: Provider select black. You may need to pip install black on the comma
@discdiver
discdiver / common_pandas_errors.md
Last active February 2, 2022 07:40
Common Pandas Errors

Common Pandas Errors

By Jeff Hale

Pandas Version 1.x.x

See the Source file here: https://github.com/discdiver/pandas_errors

Each error is explained, an example is shown, and then the correct code is shown, if applicable.

If you have other common errors you think would be helpful for others, please leave them in the comments and ping me on Twitter @discdiver.

import random
def call_unreliable_api():
choices = [{"data": 42}, "failure"]
res = random.choice(choices)
if res == "failure":
raise Exception("Our unreliable service failed")
else:
return res
@discdiver
discdiver / ex3.py
Last active August 2, 2022 18:09
ex3.py
import random
from prefect import flow, task # NEW ****
@task # NEW ****
def call_unreliable_api():
choices = [{"data": 42}, "failure"]
res = random.choice(choices)
if res == "failure":
raise Exception("Our unreliable service failed")
else:
@discdiver
discdiver / ex4.py
Created August 2, 2022 18:10
ex4.py
import random
from prefect import flow, task
@task(name="Get data from API", retries=4, retry_delay_seconds=2) # NEW ****
def call_unreliable_api():
choices = [{"data": 42}, "failure"]
res = random.choice(choices)
if res == "failure":
raise Exception("Our unreliable service failed")
else:
@discdiver
discdiver / ex5.py
Created August 2, 2022 18:21
ex5.py
import random
from prefect import flow, task
@task(name="Get data from API", retries=4, retry_delay_seconds=2) # NEW ****
def call_unreliable_api():
choices = [{"data": 42}, "failure"]
res = random.choice(choices)
if res == "failure":
raise Exception("Our unreliable service failed")