mdbq 3.5.7__py3-none-any.whl → 3.5.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
mdbq/aggregation/query_data.py
CHANGED
@@ -569,6 +569,7 @@ class MysqlDatasQuery:
|
|
569
569
|
'退款额_发货后': 1,
|
570
570
|
'退货量_发货后': 1,
|
571
571
|
'店铺名称': 1,
|
572
|
+
'更新时间': 1,
|
572
573
|
}
|
573
574
|
__res = []
|
574
575
|
for year in range(2024, datetime.datetime.today().year + 1):
|
@@ -582,17 +583,21 @@ class MysqlDatasQuery:
|
|
582
583
|
__res.append(df)
|
583
584
|
df = pd.concat(__res, ignore_index=True)
|
584
585
|
df['宝贝id'] = df['宝贝id'].astype(str)
|
585
|
-
df = df.groupby(['日期', '店铺名称', '宝贝id', '行业类目'], as_index=False).agg(
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
)
|
586
|
+
# df = df.groupby(['日期', '店铺名称', '宝贝id', '行业类目'], as_index=False).agg(
|
587
|
+
# **{
|
588
|
+
# '销售额': ('销售额', np.min),
|
589
|
+
# '销售量': ('销售量', np.min),
|
590
|
+
# '订单数': ('订单数', np.min),
|
591
|
+
# '退货量': ('退货量', np.max),
|
592
|
+
# '退款额': ('退款额', np.max),
|
593
|
+
# '退款额_发货后': ('退款额_发货后', np.max),
|
594
|
+
# '退货量_发货后': ('退货量_发货后', np.max),
|
595
|
+
# }
|
596
|
+
# )
|
597
|
+
# 仅保留最新日期的数据
|
598
|
+
idx = df.groupby(['日期', '店铺名称', '宝贝id'])['更新时间'].idxmax()
|
599
|
+
df = df.loc[idx]
|
600
|
+
df = df[['日期', '店铺名称', '宝贝id', '行业类目', '销售额', '销售量', '订单数', '退货量', '退款额', '退款额_发货后', '退货量_发货后']]
|
596
601
|
df['件均价'] = df.apply(lambda x: x['销售额'] / x['销售量'] if x['销售量'] > 0 else 0, axis=1).round(
|
597
602
|
0) # 两列运算, 避免除以0
|
598
603
|
df['价格带'] = df['件均价'].apply(
|
@@ -2226,13 +2231,17 @@ class MysqlDatasQuery:
|
|
2226
2231
|
__res.append(df)
|
2227
2232
|
df = pd.concat(__res, ignore_index=True)
|
2228
2233
|
df = df[df['商品id'] != '合计']
|
2229
|
-
df = df.groupby(['日期', '店铺名称', '商品id', '货号', '访客数', '成交客户数', '加购商品件数', '加购人数'],
|
2230
|
-
|
2231
|
-
|
2232
|
-
|
2233
|
-
|
2234
|
-
|
2235
|
-
)
|
2234
|
+
# df = df.groupby(['日期', '店铺名称', '商品id', '货号', '访客数', '成交客户数', '加购商品件数', '加购人数'],
|
2235
|
+
# as_index=False).agg(
|
2236
|
+
# **{
|
2237
|
+
# '成交单量': ('成交单量', np.max),
|
2238
|
+
# '成交金额': ('成交金额', np.max),
|
2239
|
+
# }
|
2240
|
+
# )
|
2241
|
+
# 仅保留最新日期的数据
|
2242
|
+
idx = df.groupby(['日期', '店铺名称', '商品id', '货号', '访客数', '成交客户数', '加购商品件数', '加购人数'])['更新时间'].idxmax()
|
2243
|
+
df = df.loc[idx]
|
2244
|
+
df = df[['日期', '店铺名称', '商品id', '货号', '访客数', '成交客户数', '加购商品件数', '加购人数', '成交单量', '成交金额']]
|
2236
2245
|
self.pf_datas_jd.append(
|
2237
2246
|
{
|
2238
2247
|
'集合名称': table_name,
|
@@ -2313,13 +2322,17 @@ class MysqlDatasQuery:
|
|
2313
2322
|
__res.append(df)
|
2314
2323
|
df = pd.concat(__res, ignore_index=True)
|
2315
2324
|
df = df[df['商品id'] != '合计']
|
2316
|
-
df = df.groupby(['日期', '店铺名称', '商品id', '货号', '访客数', '成交客户数', '加购商品件数', '加购人数'],
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2321
|
-
|
2322
|
-
)
|
2325
|
+
# df = df.groupby(['日期', '店铺名称', '商品id', '货号', '访客数', '成交客户数', '加购商品件数', '加购人数'],
|
2326
|
+
# as_index=False).agg(
|
2327
|
+
# **{
|
2328
|
+
# '成交单量': ('成交单量', np.max),
|
2329
|
+
# '成交金额': ('成交金额', np.max),
|
2330
|
+
# }
|
2331
|
+
# )
|
2332
|
+
# 仅保留最新日期的数据
|
2333
|
+
idx = df.groupby(['日期', '店铺名称', '商品id', '货号', '访客数', '成交客户数', '加购商品件数', '加购人数'])['更新时间'].idxmax()
|
2334
|
+
df = df.loc[idx]
|
2335
|
+
df = df[['日期', '店铺名称', '商品id', '货号', '访客数', '成交客户数', '加购商品件数', '加购人数', '成交单量', '成交金额']]
|
2323
2336
|
set_typ = {
|
2324
2337
|
'日期': 'date',
|
2325
2338
|
'店铺名称': 'varchar(100)',
|
@@ -2391,6 +2404,7 @@ class MysqlDatasQuery:
|
|
2391
2404
|
'新访客': 1,
|
2392
2405
|
'客单价': 1,
|
2393
2406
|
'uv价值': 1,
|
2407
|
+
'更新时间': 1,
|
2394
2408
|
}
|
2395
2409
|
__res = []
|
2396
2410
|
for year in range(2024, datetime.datetime.today().year+1):
|
@@ -2403,19 +2417,23 @@ class MysqlDatasQuery:
|
|
2403
2417
|
)
|
2404
2418
|
__res.append(df)
|
2405
2419
|
df = pd.concat(__res, ignore_index=True)
|
2406
|
-
df = df.groupby(
|
2407
|
-
|
2408
|
-
|
2409
|
-
|
2410
|
-
|
2411
|
-
|
2412
|
-
|
2413
|
-
|
2414
|
-
|
2415
|
-
|
2416
|
-
|
2417
|
-
|
2418
|
-
)
|
2420
|
+
# df = df.groupby(
|
2421
|
+
# ['日期', '店铺名称', '词类型', '搜索词'],
|
2422
|
+
# as_index=False).agg(
|
2423
|
+
# **{
|
2424
|
+
# '访客数': ('访客数', np.max),
|
2425
|
+
# '加购人数': ('加购人数', np.max),
|
2426
|
+
# '支付金额': ('支付金额', np.max),
|
2427
|
+
# '支付转化率': ('支付转化率', np.max),
|
2428
|
+
# '支付买家数': ('支付买家数', np.max),
|
2429
|
+
# '客单价': ('客单价', np.max),
|
2430
|
+
# 'uv价值': ('uv价值', np.max)
|
2431
|
+
# }
|
2432
|
+
# )
|
2433
|
+
idx = df.groupby(['日期', '店铺名称', '词类型', '搜索词'])['更新时间'].idxmax()
|
2434
|
+
df = df.loc[idx]
|
2435
|
+
df = df[['日期', '店铺名称', '词类型', '搜索词', '访客数', '加购人数', '支付金额', '支付转化率', '支付买家数', '客单价', 'uv价值']]
|
2436
|
+
|
2419
2437
|
set_typ = {
|
2420
2438
|
'日期': 'date',
|
2421
2439
|
'店铺名称': 'varchar(100)',
|
@@ -4179,5 +4197,5 @@ if __name__ == '__main__':
|
|
4179
4197
|
# )
|
4180
4198
|
|
4181
4199
|
sdq = MysqlDatasQuery() # 实例化数据处理类
|
4182
|
-
sdq.months = 3
|
4183
|
-
sdq.
|
4200
|
+
sdq.months = 3 # 设置数据周期, 1 表示近 2 个月
|
4201
|
+
sdq.se_search(db_name='聚合数据', table_name='天猫店铺来源_手淘搜索')
|
@@ -4,7 +4,7 @@ mdbq/aggregation/__init__.py,sha256=EeDqX2Aml6SPx8363J-v1lz0EcZtgwIBYyCJV6CcEDU,
|
|
4
4
|
mdbq/aggregation/aggregation.py,sha256=-yzApnlqSN2L0E1YMu5ml-W827qpKQvWPCOI7jj2kzY,80264
|
5
5
|
mdbq/aggregation/datashow.py,sha256=1AYSIDkdUx-4as1Ax2rPj0cExM9d-qFMrFYLAaPHNuk,54962
|
6
6
|
mdbq/aggregation/optimize_data.py,sha256=RXIv7cACCgYyehAxMjUYi_S7rVyjIwXKWMaM3nduGtA,3068
|
7
|
-
mdbq/aggregation/query_data.py,sha256=
|
7
|
+
mdbq/aggregation/query_data.py,sha256=3sQgiMcsQU5QzBvokmc3ED-UMlaQLkbKE-gLvE-XyvA,192951
|
8
8
|
mdbq/bdup/__init__.py,sha256=AkhsGk81SkG1c8FqDH5tRq-8MZmFobVbN60DTyukYTY,28
|
9
9
|
mdbq/bdup/bdup.py,sha256=LAV0TgnQpc-LB-YuJthxb0U42_VkPidzQzAagan46lU,4234
|
10
10
|
mdbq/config/__init__.py,sha256=jso1oHcy6cJEfa7udS_9uO5X6kZLoPBF8l3wCYmr5dM,18
|
@@ -36,7 +36,7 @@ mdbq/redis/__init__.py,sha256=YtgBlVSMDphtpwYX248wGge1x-Ex_mMufz4-8W0XRmA,12
|
|
36
36
|
mdbq/redis/getredis.py,sha256=PlWAGMC-WqdZtyvtjjj-i0i8AiBsNP6zgAUb5Fdkark,8481
|
37
37
|
mdbq/spider/__init__.py,sha256=RBMFXGy_jd1HXZhngB2T2XTvJqki8P_Fr-pBcwijnew,18
|
38
38
|
mdbq/spider/aikucun.py,sha256=v7VO5gtEXR6_4Q6ujbTyu1FHu7TXHcwSQ6hIO249YH0,22208
|
39
|
-
mdbq-3.5.
|
40
|
-
mdbq-3.5.
|
41
|
-
mdbq-3.5.
|
42
|
-
mdbq-3.5.
|
39
|
+
mdbq-3.5.9.dist-info/METADATA,sha256=MplUpnGT5l0iy7c7S8GxQ6TlUEgLibOVJdcIp487lis,243
|
40
|
+
mdbq-3.5.9.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
41
|
+
mdbq-3.5.9.dist-info/top_level.txt,sha256=2FQ-uLnCSB-OwFiWntzmwosW3X2Xqsg0ewh1axsaylA,5
|
42
|
+
mdbq-3.5.9.dist-info/RECORD,,
|
File without changes
|
File without changes
|