python - 如何根据数据列对不规则数据集进行上采样?
问题描述
我有一个熊猫数据框,其中包含基于深度的记录数据。深度不规则地间隔开。我需要以常规的 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 或其他库函数
解决方案
我最终interp1d
从signal
包裹中取出。
推荐阅读
- javascript - “dest.on 不是函数”将 postcss-rtl 与 gulp v4 结合使用
- c# - 使用 CodeBehind 布尔值更新控件的可见性
- json - 使用 jq 合并具有公共 id 的键
- c# - System.Diagnostics.Trace 删除默认 Trace
- python - 无法使用 SetWindowsHookEx 和注入的 DLL 连接到 Microsoft Store 应用程序
- android - RecyclerView 总是在其他视图之上
- tryton - 创建记录后如何在 tryton 中调用自定义函数?
- javascript - 如何选择jQuery变量的内部
- xcode - 如何使用 Xcode UI Recording 从 CarPlay 访问所有 UI 元素?
- c# - System.Net.Http.HttpRequestException:将内容复制到流时出错。---> System.IO.IOException: 响应提前结束