Skip to content

Instantly share code, notes, and snippets.

@simomarsili
simomarsili / script_with_input.py
Last active September 24, 2020 10:24
Template script reading from input file
"""
Template script with input file.
Use the module docstring as the script description.
Example usage: script.py -a 100 < infile
"""
import sys
from argparse import ArgumentParser, FileType
@simomarsili
simomarsili / which.py
Last active September 17, 2020 10:05
which.py
def which(cmd):
"""Path to executable `cmd`.
Args:
cmd (str or list): Name of the executable or list of alternative names.
Returns:
pathlib.Path: Path to executable (the first recoverable path for a list).
"""
# -*- coding: utf-8 -*-
"""System info"""
import platform
import sys
import numpy
import subprocess
print(
@simomarsili
simomarsili / prophet_holidays.py
Last active April 10, 2019 14:21
holidays dataframe for prophet forecasts (https://github.com/facebook/prophet)
def holidays_df():
"""
Return a pd.DataFrame with holiday data for fb prophet.
The df has columns 'holiday' (string) and 'ds' (date type)
and optionally columns lower_window and upper_window which specify a
range of days around the date to be included as holidays.
original code here: https://github.com/peridoteagle/brew/blob/master/time_series/prophet.py
"""