Skip to content

Instantly share code, notes, and snippets.

@keyapi
keyapi / retry.py
Created March 29, 2020 20:07 — forked from FBosler/retry.py
retry.py
from functools import wraps
import time
import logging
import random
logger = logging.getLogger(__name__)
def retry(exceptions, total_tries=4, initial_wait=0.5, backoff_factor=2, logger=None):
"""
@keyapi
keyapi / common_pandas_errors.ipynb
Created February 24, 2020 09:37 — forked from discdiver/common_pandas_errors.md
Common Pandas Errors
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@keyapi
keyapi / google_sheets_from_heroku.py
Created February 21, 2020 13:15 — forked from hpiwowar/google_sheets_from_heroku.py
read and write to a google spreadsheet from heroku using python
import os
import json
import gspread
from oauth2client.service_account import ServiceAccountCredentials
# based on https://www.twilio.com/blog/2017/02/an-easy-way-to-read-and-write-to-a-google-spreadsheet-in-python.html
# read that file for how to generate the creds and how to use gspread to read and write to the spreadsheet
# use creds to create a client to interact with the Google Drive API
scopes = ['https://spreadsheets.google.com/feeds']
@keyapi
keyapi / vec_func
Created August 29, 2019 08:06 — forked from bd317/vec_func
def soc_iter(TEAM,home,away,ftr):
df['Draws'] = 'No_Game'
df.loc[((home == TEAM) & (ftr == 'D')) | ((away == TEAM) & (ftr == 'D')), 'Draws'] = 'Draw'
df.loc[((home == TEAM) & (ftr != 'D')) | ((away == TEAM) & (ftr != 'D')), 'Draws'] = 'No_Draw'