过滤 df、操作其内容然后将这些更改应用到原始 df 的方法?
我需要使用 ffill 和 bfill 对 DF1 的特定部分进行一些缺失值插补。我需要通过一些文本(“A”,“B”,单独)过滤列(“字母”)。过滤后,我需要使用 ffill 和 bfill 替换“值”列中的缺失值。之后,我需要将这个新的、过滤后的 DF2 合并到原始 DF1。
我怎样才能实现这个目标?我陷入困境,无法替换 DF1 中的 DF2 值。
Index Letters Values
1 A 3
2 A NaN
3 B NaN
4 B 5
5 B 6
6 A 8
7 A NaN
I need to do some missing value imputation using ffill and bfill to a specific part of DF1. I need to filter a column ("Letters") by some text ("A", "B", individually). Once filtered, I need to replace missing values in column "Values" using ffill, and bfill. After that, I need to merge this new, filtered DF2 to the original DF1.
How can I achieve this? I´m stuck, unable to replace the DF2 values in DF1.
Index Letters Values
1 A 3
2 A NaN
3 B NaN
4 B 5
5 B 6
6 A 8
7 A NaN
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
设法用 pd.update() 做到这一点!
managed to do it with pd.update()!