首页 > 解决方案 > 如何根据数据列对不规则数据集进行上采样?

问题描述

我有一个熊猫数据框,其中包含基于深度的记录数据。深度不规则地间隔开。我需要以常规的 dx 步骤分隔数据集。

有没有办法做到这一点而不将其填充到单独的 numpy 数组中并单独插入它们?

所有列的单独插值。

df=pd.DataFrame(np.array([[0. ,   2. ,   3.5,   5. ,   6. ,  18.], [100,  20, 150,  80, 110, 125], [1.  ,  0.5 ,  2.6 ,  0.01,  3.  ,  2.]]).T, columns=['depth', 'value1', 'value2'])

step=0.05
# this is what the column "depth" should be like afterwards
target_depth=np.linspace(df['a'].min(),df['a'].max(),int(df['a'].max()/step))

进行插值/重采样的 pandas 或其他库函数

标签: pythonpandasresampling

解决方案


我最终interp1dsignal包裹中取出。


推荐阅读