util.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:croissance 作者: biosustain 项目源码 文件源码
def resample(series, *, factor=10, size=None):
    """
    Returns a new series re-sampled to a given number of points.

    :param series:
    :param factor: a number of points per unit time to scale the series to.
    :param size: a number of points to scale the series to.
    :return:
    """
    series = series.dropna()
    start, end = series.index[0], series.index[-1]

    if size is None:
        size = (end - start) * factor

    index = numpy.linspace(start, end, size)
    spline = InterpolatedUnivariateSpline(series.index, series.values)
    return pandas.Series(index=index, data=spline(index))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号