pandas.series.interpolate 的系数

问题描述 投票:0回答:1

我有一个为期一年的 pandas 系列简介,间隔为 1 小时。我以“1 分钟”的间隔对该系列进行插值和重新采样。我使用 method='spline' 和 order=2 进行插值。假设,我有 X 作为 pandas 系列,我得到 Y 如下: Y = X.resample('1min').interpolate(method = 'spline', order = 2)

是否可以获取用于样条方法得到 Y 的系数?

我无法从 pandas 文档中找到任何方法。我尝试通过将 X 值转换为数组来使用 scipy。但我找不到如何在值之间插入 60 个点以接收 y 并从 y 获取系数。

pandas interpolation series
1个回答
0
投票

pandas 将您的系列传递给 scipy.interpolate.UnivariateSpline。您可以使用 get_coeffs() 方法获取系数。

import pandas as pd
from scipy.interpolate import UnivariateSpline as usp
x = pd.Series([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
y = pd.Series([2, 3, 2, 5, 3, 6, 3, 7, 5, 8])
spl = usp(x = x.values, y = y.values, k=2)
coef = spl.get_coeffs()
© www.soinside.com 2019 - 2024. All rights reserved.