Commit 0e084865 by hejiangming

no message

parent 487285d7
......@@ -346,10 +346,24 @@ class DwtBsTop100(Templates):
# ============================================================
print("处理卖家所属地")
c = F.col("seller_country_name")
self.df_bs_data = self.df_bs_data.withColumn("seller_country_us_rate", F.when(c == "US", True).otherwise(False))
self.df_bs_data = self.df_bs_data.withColumn("seller_country_cn_rate", F.when(c == "CN", True).otherwise(False))
# 【自营算美国】Amazon 自营(buy_box 卖家类型=1)没有第三方卖家,seller_country_name 为空,
# 原来全落进"其他国家"(某些类目高达 73%,实为自营)。与选品页对齐:后端对自营固定返回
# siteName='us',故这里也把自营算美国。
# coalesce 兜底:asin_buy_box_seller_type 为 null 时当作非自营,避免下面 ~is_self 变 null 把该行漏出三档之外。
is_self = F.coalesce(F.col("asin_buy_box_seller_type") == 1, F.lit(False))
# 三档必须一起加自营条件、保持互斥穷尽(占比之和恒=1):
# 只给美国加的话,"自营+CN" 会同时命中美国和中国,两个占比相加 >1。
# 旧:只看 seller_country_name,自营(国家空)全进其他
# self.df_bs_data = self.df_bs_data.withColumn("seller_country_us_rate", F.when(c == "US", True).otherwise(False))
# self.df_bs_data = self.df_bs_data.withColumn("seller_country_cn_rate", F.when(c == "CN", True).otherwise(False))
# self.df_bs_data = self.df_bs_data.withColumn("seller_country_other_rate",
# F.when((c == "US") | (c == "CN"), False).otherwise(True))
self.df_bs_data = self.df_bs_data.withColumn("seller_country_us_rate",
F.when(is_self | (c == "US"), True).otherwise(False))
self.df_bs_data = self.df_bs_data.withColumn("seller_country_cn_rate",
F.when(~is_self & (c == "CN"), True).otherwise(False))
self.df_bs_data = self.df_bs_data.withColumn("seller_country_other_rate",
F.when((c == "US") | (c == "CN"), False).otherwise(True))
F.when(is_self | (c == "US") | (c == "CN"), False).otherwise(True))
# ============================================================
# 【ASIN 月销 50+/100+/200+ 占比】:月销≥阈值的 asin 数 ÷ 分类总 asin 数(数量占比)。
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment