Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
Amazon-Selection-Data
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abel_cjy
Amazon-Selection-Data
Commits
0e084865
Commit
0e084865
authored
Aug 10, 2026
by
hejiangming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
487285d7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
dwt_bs_top100.py
Pyspark_job/dwt/dwt_bs_top100.py
+17
-3
No files found.
Pyspark_job/dwt/dwt_bs_top100.py
View file @
0e084865
...
...
@@ -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 数(数量占比)。
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment