Skip to content

Instantly share code, notes, and snippets.

@eliorc
eliorc / cyclical_encoder.py
Last active February 27, 2019 14:32
Generate cyclic time features on pandas.DataFrame using a pandas.DateTime column
from itertools import count
import pandas as pd
import numpy as np
def cyclical_encoder(data: pd.DataFrame,
time_column: str,
time_unit: str,
normalize_val: float,
label_suffix: str) -> pd.DataFrame:
@eliorc
eliorc / permutation_t_test.py
Last active January 14, 2019 15:07
Permutation T-test (statistical)
import numpy as np
from scipy import stats
def permutation_t_test(sample1: list, sample2: list, n: int =10000) -> float:
"""
Conduct a permutation T-test using n iterations and p-value. The higher the p-value, the more likely that sample1
and sample2 are sampled from the same distribution
:param sample1: Sample of continuous observations