python - 根据单独的值与不同数据框的关系更改数据框中的值
问题描述
我有一个看起来像这样的df:
FiscalPeriod , VendorNum, Bool_1, Bool_2, Bool_3
1 , 0001 , False, False , True
2 , 0002 , True, False , True
然后我的 bool_df 看起来像这样:
VendorNum , Bools , 1, 2, 3
0001 , Bool_1 , True, False , True
0002 , Bool_1 , True, False , True
0001 , Bool_2 , True, False , True
0001 , Bool_3 , False, False , True
我想写一些东西来改变第一个 df 中相应的 Bool 列,以便它们只在会计期间列有一个数字,其相应的 bool_df 列对于该 bool 为 true 时才会读取,因此结果如下。
FiscalPeriod , VendorNum, Bool_1, Bool_2, Bool_3
1 , 0001 , **True,** **True** , **False**
2 , 0002 , **False**, False , True
我已经用粗体标出了要进行更改的地方。
解决方案
推荐阅读
- python - 流场块内的鹡鸰大列表
- c# - 如何解决 .Net core 3.1 中的“无法加载类型'Microsoft.AspNetCore.Mvc.MvcJsonOptions'”?
- node.js - 尽管尝试使用 Node12.x 在 AWS Lambda 上捕获,但未处理的 Promise Rejection
- vim - 在没有插件的情况下在 Vim 中使用自动保存?
- google-analytics - 取消自定义维度的嵌套时,GA 网页浏览量与 BigQuery 不匹配?
- python - 使用用户输入调用特定的 python 类
- java - 在嵌套地图中重用弹簧配置属性
- c++ - 你能有 constexpr 右值吗?
- javascript - 使用 Chrome 扩展从 Gmail DOM 获取元素
- assembly - 将数据从内存(可以是任意长度)移动到 XMM