You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用pyjanitor同时基于日期范围与多列实现条件连接?

用pyjanitor多条件合并DataFrame的问题

想要使用pyjanitor的conditional_join方法合并DataFrame,目前仅实现了按日期范围的条件:InvoiceDate介于PromotionStart和PromotionEnd之间,但需要同时结合其他列的匹配条件,不过官方文档未说明该如何操作。

尝试代码

df_1.conditional_join(
    df_2,
    ("InvoiceDate ", "PromotionStart ", ">="),
    ("InvoiceDate ", "PromotionEnd ", "<=")
)

当前输出结果

LocationNoInvoiceDateInvoiceAmountPromotion
A01-Jul-2079Yes
B01-Jul-2072
C01-Jul-2024
A02-Jul-2068Yes
B02-Jul-206Yes
C02-Jul-2027
A03-Jul-2025
B03-Jul-2062Yes
C03-Jul-2058Yes
D03-Jul-2036Yes
E03-Jul-2065
F03-Jul-2081

内容的提问来源于stack exchange,提问作者Jack

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 22:35:20