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

如何分组数据并将Revenue为0行的Cost汇总至同组非0Revenue行

数据处理需求
  • 分组依据:除date列外的所有列(dim_channel_group、dim_channel、dim_hotel_name、dim_market)
  • 处理规则:
    1. 仅保留Revenue不为0的行
    2. 将同组中位于目标行之前的所有Revenue为0的行的Cost值,累加到目标行的Cost中
    3. 删除所有Revenue为0的行

原始数据结构

datedim_channel_groupdim_channeldim_hotel_namedim_marketCostRevenue
10/10/2023SocialSnapchatHotel AKSA28.50
11/10/2023SocialSnapchatHotel AKSA1080
12/10/2023SocialSnapchatHotel AKSA126.70
13/10/2023SocialSnapchatHotel AKSA156.18195.8
14/10/2023SocialSnapchatHotel AKSA120.90
15/10/2023SocialSnapchatHotel AKSA115.40
16/10/2023SocialSnapchatHotel AKSA114.62352.4
10/01/2023SearchGoogleHotel BAustralia34.10
11/01/2023SearchGoogleHotel BAustralia42.70
12/01/2023SearchGoogleHotel BAustralia93.60
13/01/2023SearchGoogleHotel BAustralia29.33500
14/01/2023SearchGoogleHotel BAustralia44.80
15/01/2023SearchGoogleHotel BAustralia88.60
16/01/2023SearchGoogleHotel BAustralia35.50
17/01/2023SearchGoogleHotel BAustralia81.97500

期望数据结构

datedim_channel_groupdim_channeldim_hotel_namedim_marketCostRevenue
13/10/2023SocialSnapchatHotel AKSA419.38195.8
16/10/2023SocialSnapchatHotel AKSA350.92352.4
13/01/2023SearchGoogleHotel BAustralia199.73500
17/01/2023SearchGoogleHotel BAustralia250.87500

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.20 08:14:54