def nearest_workday(dt):
    if dt.weekday() == 5:
        return dt - timedelta(1)
    elif dt.weekday() == 6:
        return dt + timedelta(1)
    return dt
.. todo::
dataset/ETHPy150Open pydata/pandas/pandas/tseries/holiday.py/nearest_workday--crossover with--dataset/ETHPy150Open lisa-lab/pylearn2/pylearn2/packaged_dependencies/theano_linear/pyramid.py/GaussianPyramid.perform