mdbq 2.6.2__tar.gz → 2.6.3__tar.gz
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-2.6.2 → mdbq-2.6.3}/PKG-INFO +1 -1
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/aggregation/aggregation.py +17 -15
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/aggregation/query_data.py +92 -109
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/clean/clean_upload.py +109 -100
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq.egg-info/PKG-INFO +1 -1
- {mdbq-2.6.2 → mdbq-2.6.3}/setup.py +1 -1
- {mdbq-2.6.2 → mdbq-2.6.3}/README.txt +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/__init__.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/__version__.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/aggregation/__init__.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/aggregation/df_types.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/aggregation/mysql_types.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/aggregation/optimize_data.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/bdup/__init__.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/bdup/bdup.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/clean/__init__.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/clean/data_clean.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/company/__init__.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/company/copysh.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/company/home_sh.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/config/__init__.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/config/get_myconf.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/config/products.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/config/set_support.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/config/update_conf.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/dataframe/__init__.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/dataframe/converter.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/log/__init__.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/log/mylogger.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/mongo/__init__.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/mongo/mongo.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/mysql/__init__.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/mysql/mysql.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/mysql/s_query.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/mysql/year_month_day.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/other/__init__.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/other/porxy.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/other/pov_city.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/other/sku_picture.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/other/ua_sj.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/pbix/__init__.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/pbix/pbix_refresh.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/pbix/refresh_all.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/pbix/refresh_all_old.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/req_post/__init__.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/req_post/req_tb.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/spider/__init__.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq/spider/aikucun.py +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq.egg-info/SOURCES.txt +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq.egg-info/dependency_links.txt +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/mdbq.egg-info/top_level.txt +0 -0
- {mdbq-2.6.2 → mdbq-2.6.3}/setup.cfg +0 -0
@@ -1302,25 +1302,27 @@ if __name__ == '__main__':
|
|
1302
1302
|
username, password, host, port = get_myconf.select_config_values(target_service='nas', database='mysql')
|
1303
1303
|
print(username, password, host, port)
|
1304
1304
|
# file_dir(one_file=False, target_service='company')
|
1305
|
-
# one_file_to_mysql(
|
1306
|
-
# file='/Users/xigua/Downloads/爱库存_商品榜单_spu_2024-10-17_2024-10-17.csv',
|
1307
|
-
# db_name='爱库存2',
|
1308
|
-
# table_name='商品spu榜单',
|
1309
|
-
# target_service='company',
|
1310
|
-
# database='mysql'
|
1311
|
-
# )
|
1312
1305
|
|
1313
|
-
#
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
db_name=db_name,
|
1319
|
-
collection_name=table_name,
|
1320
|
-
dbs={'mysql': True, 'mongodb': False},
|
1306
|
+
# 上传 1 个文件到数据库
|
1307
|
+
one_file_to_mysql(
|
1308
|
+
file='/Users/xigua/Downloads/万里马箱包推广1_营销概况_全站营销_2024-08-18_2024-09-01.csv',
|
1309
|
+
db_name='京东数据3',
|
1310
|
+
table_name='推广数据_全站营销',
|
1321
1311
|
target_service='company',
|
1312
|
+
database='mysql'
|
1322
1313
|
)
|
1323
1314
|
|
1315
|
+
# # 上传一个目录到指定数据库
|
1316
|
+
# db_name = '天猫_推广数据3'
|
1317
|
+
# table_name = '主体报表'
|
1318
|
+
# upload_dir(
|
1319
|
+
# path='/Users/xigua/数据中心/原始文件3/天猫推广报表/主体报表',
|
1320
|
+
# db_name=db_name,
|
1321
|
+
# collection_name=table_name,
|
1322
|
+
# dbs={'mysql': True, 'mongodb': False},
|
1323
|
+
# target_service='company',
|
1324
|
+
# )
|
1325
|
+
|
1324
1326
|
|
1325
1327
|
# # 新版 数据分类
|
1326
1328
|
# dp = DatabaseUpdate(path='/Users/xigua/Downloads')
|
@@ -120,6 +120,7 @@ class MysqlDatasQuery:
|
|
120
120
|
'自然流量曝光量': 1,
|
121
121
|
'直接成交笔数': 1,
|
122
122
|
'直接成交金额': 1,
|
123
|
+
'店铺名称': 1,
|
123
124
|
}
|
124
125
|
df = self.download.data_to_df(
|
125
126
|
db_name='推广数据2',
|
@@ -171,6 +172,7 @@ class MysqlDatasQuery:
|
|
171
172
|
'直接成交笔数': 1,
|
172
173
|
'直接成交金额': 1,
|
173
174
|
'人群名字': 1,
|
175
|
+
'店铺名称': 1,
|
174
176
|
}
|
175
177
|
df = self.download.data_to_df(
|
176
178
|
db_name='推广数据2',
|
@@ -198,6 +200,7 @@ class MysqlDatasQuery:
|
|
198
200
|
'总成交金额': 1,
|
199
201
|
'直接成交笔数': 1,
|
200
202
|
'直接成交金额': 1,
|
203
|
+
'店铺名称': 1,
|
201
204
|
}
|
202
205
|
df = self.download.data_to_df(
|
203
206
|
db_name='推广数据2',
|
@@ -226,6 +229,7 @@ class MysqlDatasQuery:
|
|
226
229
|
'总成交金额': 1,
|
227
230
|
'直接成交笔数': 1,
|
228
231
|
'直接成交金额': 1,
|
232
|
+
'店铺名称': 1,
|
229
233
|
}
|
230
234
|
df = self.download.data_to_df(
|
231
235
|
db_name='推广数据2',
|
@@ -252,6 +256,7 @@ class MysqlDatasQuery:
|
|
252
256
|
'成交笔数': 1,
|
253
257
|
'成交金额': 1,
|
254
258
|
# '成交访客数': 1
|
259
|
+
'店铺名称': 1,
|
255
260
|
}
|
256
261
|
df = self.download.data_to_df(
|
257
262
|
db_name='推广数据2',
|
@@ -277,8 +282,8 @@ class MysqlDatasQuery:
|
|
277
282
|
def sp_picture(self):
|
278
283
|
""" 用生意经日数据制作商品 id 和编码对照表 """
|
279
284
|
data_values = self.download.columns_to_list(
|
280
|
-
db_name='属性设置
|
281
|
-
table_name='
|
285
|
+
db_name='属性设置3',
|
286
|
+
table_name='商品素材中心',
|
282
287
|
columns_name=['日期', '商品id', '商品白底图', '方版场景图'],
|
283
288
|
)
|
284
289
|
df = pd.DataFrame(data=data_values)
|
@@ -298,14 +303,16 @@ class MysqlDatasQuery:
|
|
298
303
|
'支付买家数': 1,
|
299
304
|
'支付转化率': 1,
|
300
305
|
'加购人数': 1,
|
306
|
+
'店铺名称': 1,
|
301
307
|
}
|
302
308
|
df = self.download.data_to_df(
|
303
|
-
db_name='生意参谋
|
304
|
-
table_name='
|
309
|
+
db_name='生意参谋3',
|
310
|
+
table_name='店铺流量来源构成',
|
305
311
|
start_date=start_date,
|
306
312
|
end_date=end_date,
|
307
313
|
projection=projection,
|
308
314
|
)
|
315
|
+
# df = df[df['店铺名称'] == '万里马官方旗舰店']
|
309
316
|
return df
|
310
317
|
|
311
318
|
@try_except
|
@@ -335,7 +342,7 @@ class MysqlDatasQuery:
|
|
335
342
|
def sp_cost(self):
|
336
343
|
""" 电商定价 """
|
337
344
|
data_values = self.download.columns_to_list(
|
338
|
-
db_name='属性设置
|
345
|
+
db_name='属性设置3',
|
339
346
|
table_name='电商定价',
|
340
347
|
columns_name=['日期', '款号', '年份季节', '吊牌价', '商家平台', '成本价', '天猫页面价', '天猫中促价'],
|
341
348
|
)
|
@@ -360,9 +367,10 @@ class MysqlDatasQuery:
|
|
360
367
|
'直接加购数': 1,
|
361
368
|
'总加购数': 1,
|
362
369
|
'spu id': 1,
|
370
|
+
'店铺名称':1,
|
363
371
|
}
|
364
372
|
df = self.download.data_to_df(
|
365
|
-
db_name='京东数据
|
373
|
+
db_name='京东数据3',
|
366
374
|
table_name='推广数据_京准通',
|
367
375
|
start_date=start_date,
|
368
376
|
end_date=end_date,
|
@@ -386,8 +394,8 @@ class MysqlDatasQuery:
|
|
386
394
|
'核心位置点击量': 1,
|
387
395
|
}
|
388
396
|
df = self.download.data_to_df(
|
389
|
-
db_name='京东数据
|
390
|
-
table_name='推广数据_全站营销',
|
397
|
+
db_name='京东数据3',
|
398
|
+
table_name='推广数据_全站营销', # 暂缺
|
391
399
|
start_date=start_date,
|
392
400
|
end_date=end_date,
|
393
401
|
projection=projection,
|
@@ -415,13 +423,13 @@ class MysqlDatasQuery:
|
|
415
423
|
'总订单行': 1,
|
416
424
|
'总订单金额': 1,
|
417
425
|
'总加购数': 1,
|
418
|
-
'
|
426
|
+
'下单新客数(去重)': 1,
|
419
427
|
'领券数': 1,
|
420
428
|
'商品关注数': 1,
|
421
|
-
'店铺关注数': 1
|
429
|
+
'店铺关注数': 1,
|
422
430
|
}
|
423
431
|
df = self.download.data_to_df(
|
424
|
-
db_name='京东数据
|
432
|
+
db_name='京东数据3',
|
425
433
|
table_name='推广数据_关键词报表',
|
426
434
|
start_date=start_date,
|
427
435
|
end_date=end_date,
|
@@ -444,8 +452,8 @@ class MysqlDatasQuery:
|
|
444
452
|
'加购人数': 1,
|
445
453
|
}
|
446
454
|
df = self.download.data_to_df(
|
447
|
-
db_name='京东数据
|
448
|
-
table_name='
|
455
|
+
db_name='京东数据3',
|
456
|
+
table_name='京东商智_sku_商品明细',
|
449
457
|
start_date=start_date,
|
450
458
|
end_date=end_date,
|
451
459
|
projection=projection,
|
@@ -467,8 +475,8 @@ class MysqlDatasQuery:
|
|
467
475
|
'加购人数': 1,
|
468
476
|
}
|
469
477
|
df = self.download.data_to_df(
|
470
|
-
db_name='京东数据
|
471
|
-
table_name='
|
478
|
+
db_name='京东数据3',
|
479
|
+
table_name='京东商智_spu_商品明细',
|
472
480
|
start_date=start_date,
|
473
481
|
end_date=end_date,
|
474
482
|
projection=projection,
|
@@ -498,9 +506,10 @@ class MysqlDatasQuery:
|
|
498
506
|
'下单买家数': 1,
|
499
507
|
'加购人数': 1,
|
500
508
|
'新访客': 1,
|
509
|
+
'店铺名称': 1,
|
501
510
|
}
|
502
511
|
df = self.download.data_to_df(
|
503
|
-
db_name='生意参谋
|
512
|
+
db_name='生意参谋3',
|
504
513
|
table_name='店铺来源_手淘搜索',
|
505
514
|
start_date=start_date,
|
506
515
|
end_date=end_date,
|
@@ -543,9 +552,10 @@ class MysqlDatasQuery:
|
|
543
552
|
'退款金额(元)': 1,
|
544
553
|
'预售定金支付金额(元)': 1,
|
545
554
|
'预售预估总金额(元)': 1,
|
555
|
+
'店铺名称': 1,
|
546
556
|
}
|
547
557
|
df = self.download.data_to_df(
|
548
|
-
db_name='生意参谋
|
558
|
+
db_name='生意参谋3',
|
549
559
|
table_name='直播场次分析',
|
550
560
|
start_date=start_date,
|
551
561
|
end_date=end_date,
|
@@ -553,7 +563,7 @@ class MysqlDatasQuery:
|
|
553
563
|
)
|
554
564
|
return df
|
555
565
|
|
556
|
-
@try_except
|
566
|
+
# @try_except
|
557
567
|
def tg_by_day(self):
|
558
568
|
"""
|
559
569
|
汇总各个店铺的推广数据,按日汇总
|
@@ -568,6 +578,7 @@ class MysqlDatasQuery:
|
|
568
578
|
'总购物车数': 1,
|
569
579
|
'总成交笔数': 1,
|
570
580
|
'总成交金额': 1,
|
581
|
+
'店铺名称': 1,
|
571
582
|
}
|
572
583
|
df_tm = self.download.data_to_df(
|
573
584
|
db_name='推广数据2',
|
@@ -578,7 +589,7 @@ class MysqlDatasQuery:
|
|
578
589
|
)
|
579
590
|
df_tm.rename(columns={'场景名字': '营销场景'}, inplace=True)
|
580
591
|
df_tm = df_tm.groupby(
|
581
|
-
['日期', '营销场景', '花费'],
|
592
|
+
['日期', '店铺名称', '营销场景', '花费'],
|
582
593
|
as_index=False).agg(
|
583
594
|
**{
|
584
595
|
'展现量': ('展现量', np.max),
|
@@ -588,7 +599,6 @@ class MysqlDatasQuery:
|
|
588
599
|
'成交金额': ('总成交金额', np.max)
|
589
600
|
}
|
590
601
|
)
|
591
|
-
df_tm.insert(loc=1, column='店铺', value='WLM天猫旗舰店') # df中添加列
|
592
602
|
|
593
603
|
df_tb = self.download.data_to_df(
|
594
604
|
db_name='推广数据_淘宝店',
|
@@ -602,7 +612,7 @@ class MysqlDatasQuery:
|
|
602
612
|
# df_tb.to_csv('/Users/xigua/Downloads/test.csv', index=False, header=True, encoding='utf-8_sig')
|
603
613
|
df_tb.rename(columns={'场景名字': '营销场景'}, inplace=True)
|
604
614
|
df_tb = df_tb.groupby(
|
605
|
-
['日期', '营销场景', '花费'],
|
615
|
+
['日期', '店铺名称', '营销场景', '花费'],
|
606
616
|
as_index=False).agg(
|
607
617
|
**{
|
608
618
|
'展现量': ('展现量', np.max),
|
@@ -612,7 +622,6 @@ class MysqlDatasQuery:
|
|
612
622
|
'成交金额': ('总成交金额', np.max)
|
613
623
|
}
|
614
624
|
)
|
615
|
-
df_tb.insert(loc=1, column='店铺', value='淘宝c店') # df中添加列
|
616
625
|
|
617
626
|
projection = {
|
618
627
|
'日期': 1,
|
@@ -623,6 +632,7 @@ class MysqlDatasQuery:
|
|
623
632
|
'宝贝加购数': 1,
|
624
633
|
'成交笔数': 1,
|
625
634
|
'成交金额': 1,
|
635
|
+
'店铺名称': 1,
|
626
636
|
}
|
627
637
|
df_tm_pxb = self.download.data_to_df(
|
628
638
|
db_name='推广数据2',
|
@@ -633,7 +643,7 @@ class MysqlDatasQuery:
|
|
633
643
|
)
|
634
644
|
df_tm_pxb = df_tm_pxb[df_tm_pxb['报表类型'] == '账户']
|
635
645
|
df_tm_pxb = df_tm_pxb.groupby(
|
636
|
-
['日期', '报表类型', '消耗'],
|
646
|
+
['日期', '店铺名称', '报表类型', '消耗'],
|
637
647
|
as_index=False).agg(
|
638
648
|
**{
|
639
649
|
'展现量': ('展现量', np.max),
|
@@ -645,7 +655,6 @@ class MysqlDatasQuery:
|
|
645
655
|
)
|
646
656
|
df_tm_pxb.rename(columns={'报表类型': '营销场景', '消耗': '花费'}, inplace=True)
|
647
657
|
df_tm_pxb['营销场景'] = '品销宝'
|
648
|
-
df_tm_pxb.insert(loc=1, column='店铺', value='WLM天猫旗舰店') # df中添加列
|
649
658
|
|
650
659
|
projection = {
|
651
660
|
'日期': 1,
|
@@ -662,15 +671,16 @@ class MysqlDatasQuery:
|
|
662
671
|
'直接加购数': 1,
|
663
672
|
'总加购数': 1,
|
664
673
|
'spu id': 1,
|
674
|
+
'店铺名称': 1,
|
665
675
|
}
|
666
676
|
df_jd = self.download.data_to_df(
|
667
|
-
db_name='京东数据
|
677
|
+
db_name='京东数据3',
|
668
678
|
table_name='推广数据_京准通',
|
669
679
|
start_date=start_date,
|
670
680
|
end_date=end_date,
|
671
681
|
projection=projection,
|
672
682
|
)
|
673
|
-
df_jd = df_jd.groupby(['日期', '产品线', '触发sku id', '跟单sku id', 'spu id', '花费', '展现数', '点击数'],
|
683
|
+
df_jd = df_jd.groupby(['日期', '店铺名称', '产品线', '触发sku id', '跟单sku id', 'spu id', '花费', '展现数', '点击数'],
|
674
684
|
as_index=False).agg(
|
675
685
|
**{'直接订单行': ('直接订单行', np.max),
|
676
686
|
'直接订单金额': ('直接订单金额', np.max),
|
@@ -680,10 +690,9 @@ class MysqlDatasQuery:
|
|
680
690
|
'加购量': ('总加购数', np.max),
|
681
691
|
}
|
682
692
|
)
|
683
|
-
df_jd = df_jd[['日期', '产品线', '花费', '展现数', '点击数', '加购量', '成交笔数', '成交金额']]
|
693
|
+
df_jd = df_jd[['日期', '店铺名称', '产品线', '花费', '展现数', '点击数', '加购量', '成交笔数', '成交金额']]
|
684
694
|
df_jd.rename(columns={'产品线': '营销场景', '展现数': '展现量', '点击数': '点击量'}, inplace=True)
|
685
695
|
df_jd = df_jd[df_jd['花费'] > 0]
|
686
|
-
df_jd.insert(loc=1, column='店铺', value='京东箱包') # df中添加列
|
687
696
|
|
688
697
|
projection = {
|
689
698
|
'日期': 1,
|
@@ -696,15 +705,16 @@ class MysqlDatasQuery:
|
|
696
705
|
'全站费比': 1,
|
697
706
|
'核心位置展现量': 1,
|
698
707
|
'核心位置点击量': 1,
|
708
|
+
'店铺名称': 1,
|
699
709
|
}
|
700
710
|
df_jd_qzyx = self.download.data_to_df(
|
701
|
-
db_name='京东数据
|
711
|
+
db_name='京东数据3',
|
702
712
|
table_name='推广数据_全站营销',
|
703
713
|
start_date=start_date,
|
704
714
|
end_date=end_date,
|
705
715
|
projection=projection,
|
706
716
|
)
|
707
|
-
df_jd_qzyx = df_jd_qzyx.groupby(['日期', '产品线', '花费'], as_index=False).agg(
|
717
|
+
df_jd_qzyx = df_jd_qzyx.groupby(['日期', '店铺名称', '产品线', '花费'], as_index=False).agg(
|
708
718
|
**{'全站roi': ('全站roi', np.max),
|
709
719
|
'成交金额': ('全站交易额', np.max),
|
710
720
|
'成交笔数': ('全站订单行', np.max),
|
@@ -715,9 +725,8 @@ class MysqlDatasQuery:
|
|
715
725
|
}
|
716
726
|
)
|
717
727
|
df_jd_qzyx.rename(columns={'产品线': '营销场景'}, inplace=True)
|
718
|
-
df_jd_qzyx = df_jd_qzyx[['日期', '营销场景', '花费', '展现量', '点击量', '成交笔数', '成交金额']]
|
728
|
+
df_jd_qzyx = df_jd_qzyx[['日期', '店铺名称', '营销场景', '花费', '展现量', '点击量', '成交笔数', '成交金额']]
|
719
729
|
df_jd_qzyx = df_jd_qzyx[df_jd_qzyx['花费'] > 0]
|
720
|
-
df_jd_qzyx.insert(loc=1, column='店铺', value='京东箱包') # df中添加列
|
721
730
|
|
722
731
|
_datas = [item for item in [df_tm, df_tb, df_tm_pxb, df_jd, df_jd_qzyx] if len(item) > 0] # 阻止空的 dataframe
|
723
732
|
df = pd.concat(_datas, axis=0, ignore_index=True)
|
@@ -760,6 +769,7 @@ class MysqlDatasQuery:
|
|
760
769
|
'sku数_成交': 1,
|
761
770
|
'营销后供货额': 1,
|
762
771
|
'营销后供货价': 1,
|
772
|
+
'店铺名称': 1,
|
763
773
|
}
|
764
774
|
projection = {}
|
765
775
|
df = self.download.data_to_df(
|
@@ -842,7 +852,7 @@ class GroupBy:
|
|
842
852
|
|
843
853
|
return wrapper
|
844
854
|
|
845
|
-
@try_except
|
855
|
+
# @try_except
|
846
856
|
def groupby(self, df, table_name, is_maximize=True):
|
847
857
|
"""
|
848
858
|
self.is_maximize: 是否最大转化数据
|
@@ -885,7 +895,7 @@ class GroupBy:
|
|
885
895
|
'直接成交金额': float,
|
886
896
|
}, errors='raise')
|
887
897
|
if is_maximize:
|
888
|
-
df = df.groupby(['日期', '营销场景', '商品id', '花费', '展现量', '点击量'], as_index=False).agg(
|
898
|
+
df = df.groupby(['日期', '店铺名称', '营销场景', '商品id', '花费', '展现量', '点击量'], as_index=False).agg(
|
889
899
|
**{'加购量': ('加购量', np.max),
|
890
900
|
'成交笔数': ('成交笔数', np.max),
|
891
901
|
'成交金额': ('成交金额', np.max),
|
@@ -895,7 +905,7 @@ class GroupBy:
|
|
895
905
|
}
|
896
906
|
)
|
897
907
|
else:
|
898
|
-
df = df.groupby(['日期', '营销场景', '商品id', '花费', '展现量', '点击量'], as_index=False).agg(
|
908
|
+
df = df.groupby(['日期', '店铺名称', '营销场景', '商品id', '花费', '展现量', '点击量'], as_index=False).agg(
|
899
909
|
**{
|
900
910
|
'加购量': ('加购量', np.min),
|
901
911
|
'成交笔数': ('成交笔数', np.min),
|
@@ -906,7 +916,7 @@ class GroupBy:
|
|
906
916
|
}
|
907
917
|
)
|
908
918
|
df.insert(loc=1, column='推广渠道', value='万相台无界版') # df中插入新列
|
909
|
-
df_new = df.groupby(['日期', '商品id'], as_index=False).agg(
|
919
|
+
df_new = df.groupby(['日期', '店铺名称', '商品id'], as_index=False).agg(
|
910
920
|
**{
|
911
921
|
'花费': ('花费', np.sum),
|
912
922
|
'成交笔数': ('成交笔数', np.max),
|
@@ -934,7 +944,8 @@ class GroupBy:
|
|
934
944
|
else:
|
935
945
|
year_my = today.year
|
936
946
|
# 截取 从上月1日 至 今天的花费数据, 推广款式按此数据从高到低排序(商品图+排序)
|
937
|
-
|
947
|
+
df_pic_lin = df[df['店铺名称'] == '万里马官方旗舰店']
|
948
|
+
df_pic = df_pic_lin.groupby(['日期', '商品id'], as_index=False).agg({'花费': 'sum'})
|
938
949
|
df_pic = df_pic[~df_pic['商品id'].isin([''])] # 指定列中删除包含空值的行
|
939
950
|
df_pic = df_pic[(df_pic['日期'] >= f'{year_my}-{last_month.month}-01')]
|
940
951
|
df_pic = df_pic.groupby(['商品id'], as_index=False).agg({'花费': 'sum'})
|
@@ -942,9 +953,9 @@ class GroupBy:
|
|
942
953
|
df_pic.reset_index(inplace=True)
|
943
954
|
df_pic['index'] = df_pic['index'] + 100
|
944
955
|
df_pic.rename(columns={'index': '商品索引'}, inplace=True)
|
945
|
-
df_pic_new = pd.merge(
|
956
|
+
df_pic_new = pd.merge(df_pic_lin, df_pic, how='left', on=['商品id'])
|
946
957
|
df_pic_new['商品索引'].fillna(1000, inplace=True)
|
947
|
-
self.sp_index_datas = df_pic_new[['商品id', '商品索引']]
|
958
|
+
self.sp_index_datas = df_pic_new[['商品id', '商品索引']] # 商品索引表_主推排序调用
|
948
959
|
return df
|
949
960
|
elif '商品索引表' in table_name:
|
950
961
|
return df
|
@@ -952,6 +963,7 @@ class GroupBy:
|
|
952
963
|
df.drop_duplicates(
|
953
964
|
subset=[
|
954
965
|
'日期',
|
966
|
+
'店铺名称',
|
955
967
|
'spu_id',
|
956
968
|
'访客量',
|
957
969
|
'浏览量',
|
@@ -981,7 +993,7 @@ class GroupBy:
|
|
981
993
|
'直接成交金额': float,
|
982
994
|
}, errors='raise')
|
983
995
|
if is_maximize:
|
984
|
-
df = df.groupby(['日期', '营销场景', '商品id', '花费', '展现量', '点击量', '人群名字'], as_index=False).agg(
|
996
|
+
df = df.groupby(['日期', '店铺名称', '营销场景', '商品id', '花费', '展现量', '点击量', '人群名字'], as_index=False).agg(
|
985
997
|
**{'加购量': ('加购量', np.max),
|
986
998
|
'成交笔数': ('成交笔数', np.max),
|
987
999
|
'成交金额': ('成交金额', np.max),
|
@@ -990,7 +1002,7 @@ class GroupBy:
|
|
990
1002
|
}
|
991
1003
|
)
|
992
1004
|
else:
|
993
|
-
df = df.groupby(['日期', '营销场景', '商品id', '花费', '展现量', '点击量', '人群名字'], as_index=False).agg(
|
1005
|
+
df = df.groupby(['日期', '店铺名称', '营销场景', '商品id', '花费', '展现量', '点击量', '人群名字'], as_index=False).agg(
|
994
1006
|
**{
|
995
1007
|
'加购量': ('加购量', np.min),
|
996
1008
|
'成交笔数': ('成交笔数', np.min),
|
@@ -1079,7 +1091,6 @@ class GroupBy:
|
|
1079
1091
|
# df.to_csv('/Users/xigua/Downloads/test_人群分类.csv', index=False, header=True, encoding='utf-8_sig')
|
1080
1092
|
# breakpoint()
|
1081
1093
|
return df
|
1082
|
-
|
1083
1094
|
elif '天猫_关键词报表' in table_name:
|
1084
1095
|
df.rename(columns={
|
1085
1096
|
'场景名字': '营销场景',
|
@@ -1101,7 +1112,7 @@ class GroupBy:
|
|
1101
1112
|
'直接成交金额': float,
|
1102
1113
|
}, errors='raise')
|
1103
1114
|
if is_maximize:
|
1104
|
-
df = df.groupby(['日期', '营销场景', '商品id', '词类型', '词名字/词包名字', '花费', '展现量', '点击量'], as_index=False).agg(
|
1115
|
+
df = df.groupby(['日期', '店铺名称', '营销场景', '商品id', '词类型', '词名字/词包名字', '花费', '展现量', '点击量'], as_index=False).agg(
|
1105
1116
|
**{'加购量': ('加购量', np.max),
|
1106
1117
|
'成交笔数': ('成交笔数', np.max),
|
1107
1118
|
'成交金额': ('成交金额', np.max),
|
@@ -1110,7 +1121,7 @@ class GroupBy:
|
|
1110
1121
|
}
|
1111
1122
|
)
|
1112
1123
|
else:
|
1113
|
-
df = df.groupby(['日期', '营销场景', '商品id', '词类型', '词名字/词包名字', '花费', '展现量', '点击量'], as_index=False).agg(
|
1124
|
+
df = df.groupby(['日期', '店铺名称', '营销场景', '商品id', '词类型', '词名字/词包名字', '花费', '展现量', '点击量'], as_index=False).agg(
|
1114
1125
|
**{
|
1115
1126
|
'加购量': ('加购量', np.min),
|
1116
1127
|
'成交笔数': ('成交笔数', np.min),
|
@@ -1166,7 +1177,7 @@ class GroupBy:
|
|
1166
1177
|
'观看次数': int,
|
1167
1178
|
}, errors='raise')
|
1168
1179
|
if is_maximize:
|
1169
|
-
df = df.groupby(['日期', '营销场景', '人群名字', '计划名字', '花费', '观看次数', '展现量'],
|
1180
|
+
df = df.groupby(['日期', '店铺名称', '营销场景', '人群名字', '计划名字', '花费', '观看次数', '展现量'],
|
1170
1181
|
as_index=False).agg(
|
1171
1182
|
**{
|
1172
1183
|
'进店量': ('进店量', np.max),
|
@@ -1179,7 +1190,7 @@ class GroupBy:
|
|
1179
1190
|
}
|
1180
1191
|
)
|
1181
1192
|
else:
|
1182
|
-
df = df.groupby(['日期', '营销场景', '人群名字', '计划名字', '花费', '观看次数', '展现量'],
|
1193
|
+
df = df.groupby(['日期', '店铺名称', '营销场景', '人群名字', '计划名字', '花费', '观看次数', '展现量'],
|
1183
1194
|
as_index=False).agg(
|
1184
1195
|
**{
|
1185
1196
|
'进店量': ('进店量', np.min),
|
@@ -1232,7 +1243,7 @@ class GroupBy:
|
|
1232
1243
|
'品牌搜索人数': int,
|
1233
1244
|
}, errors='raise')
|
1234
1245
|
if is_maximize:
|
1235
|
-
df = df.groupby(['日期', '报表类型', '花费', '展现量', '点击量'], as_index=False).agg(
|
1246
|
+
df = df.groupby(['日期', '店铺名称', '报表类型', '花费', '展现量', '点击量'], as_index=False).agg(
|
1236
1247
|
**{
|
1237
1248
|
'加购量': ('加购量', np.max),
|
1238
1249
|
'成交笔数': ('成交笔数', np.max),
|
@@ -1242,7 +1253,7 @@ class GroupBy:
|
|
1242
1253
|
}
|
1243
1254
|
)
|
1244
1255
|
else:
|
1245
|
-
df = df.groupby(['日期', '报表类型', '花费', '展现量', '点击量'], as_index=False).agg(
|
1256
|
+
df = df.groupby(['日期', '店铺名称', '报表类型', '花费', '展现量', '点击量'], as_index=False).agg(
|
1246
1257
|
**{
|
1247
1258
|
'加购量': ('加购量', np.min),
|
1248
1259
|
'成交笔数': ('成交笔数', np.min),
|
@@ -1299,35 +1310,7 @@ class GroupBy:
|
|
1299
1310
|
}
|
1300
1311
|
)
|
1301
1312
|
return df
|
1302
|
-
elif '
|
1303
|
-
# 包含三级来源名称和预设索引值列
|
1304
|
-
# 截取 从上月1日 至 今天的花费数据, 推广款式按此数据从高到低排序(商品图+排序)
|
1305
|
-
df_visitor3 = df.groupby(['日期', '三级来源'], as_index=False).agg({'访客数': 'sum'})
|
1306
|
-
df_visitor3 = df_visitor3[~df_visitor3['三级来源'].isin([''])] # 指定列中删除包含空值的行
|
1307
|
-
# df_visitor = df_visitor[(df_visitor['日期'] >= f'{year_my}-{last_month.month}-01')]
|
1308
|
-
df_visitor3 = df_visitor3.groupby(['三级来源'], as_index=False).agg({'访客数': 'sum'})
|
1309
|
-
df_visitor3.sort_values('访客数', ascending=False, ignore_index=True, inplace=True)
|
1310
|
-
df_visitor3.reset_index(inplace=True)
|
1311
|
-
df_visitor3['index'] = df_visitor3['index'] + 100
|
1312
|
-
df_visitor3.rename(columns={'index': '三级访客索引'}, inplace=True)
|
1313
|
-
df_visitor3 = df_visitor3[['三级来源', '三级访客索引']]
|
1314
|
-
|
1315
|
-
# 包含二级来源名称和预设索引值列
|
1316
|
-
df_visitor2 = df.groupby(['日期', '二级来源'], as_index=False).agg({'访客数': 'sum'})
|
1317
|
-
df_visitor2 = df_visitor2[~df_visitor2['二级来源'].isin([''])] # 指定列中删除包含空值的行
|
1318
|
-
# df_visitor2 = df_visitor2[(df_visitor2['日期'] >= f'{year_my}-{last_month.month}-01')]
|
1319
|
-
df_visitor2 = df_visitor2.groupby(['二级来源'], as_index=False).agg({'访客数': 'sum'})
|
1320
|
-
df_visitor2.sort_values('访客数', ascending=False, ignore_index=True, inplace=True)
|
1321
|
-
df_visitor2.reset_index(inplace=True)
|
1322
|
-
df_visitor2['index'] = df_visitor2['index'] + 100
|
1323
|
-
df_visitor2.rename(columns={'index': '二级访客索引'}, inplace=True)
|
1324
|
-
df_visitor2 = df_visitor2[['二级来源', '二级访客索引']]
|
1325
|
-
|
1326
|
-
df = pd.merge(df, df_visitor2, how='left', left_on='二级来源', right_on='二级来源')
|
1327
|
-
df = pd.merge(df, df_visitor3, how='left', left_on='三级来源', right_on='三级来源')
|
1328
|
-
return df
|
1329
|
-
elif '天猫_店铺来源_日数据_旧版' in table_name:
|
1330
|
-
|
1313
|
+
elif '店铺流量来源构成' in table_name:
|
1331
1314
|
# 包含三级来源名称和预设索引值列
|
1332
1315
|
# 截取 从上月1日 至 今天的花费数据, 推广款式按此数据从高到低排序(商品图+排序)
|
1333
1316
|
df_visitor3 = df.groupby(['日期', '三级来源'], as_index=False).agg({'访客数': 'sum'})
|
@@ -1409,7 +1392,7 @@ class GroupBy:
|
|
1409
1392
|
)
|
1410
1393
|
return df
|
1411
1394
|
elif '京东_京准通' in table_name and '全站营销' not in table_name:
|
1412
|
-
df = df.groupby(['日期', '产品线', '触发sku id', '跟单sku id', 'spu id', '花费', '展现数', '点击数'], as_index=False).agg(
|
1395
|
+
df = df.groupby(['日期', '店铺名称', '产品线', '触发sku id', '跟单sku id', 'spu id', '花费', '展现数', '点击数'], as_index=False).agg(
|
1413
1396
|
**{'直接订单行': ('直接订单行', np.max),
|
1414
1397
|
'直接订单金额': ('直接订单金额', np.max),
|
1415
1398
|
'总订单行': ('总订单行', np.max),
|
@@ -1479,7 +1462,7 @@ class GroupBy:
|
|
1479
1462
|
'总订单行': ('总订单行', np.max),
|
1480
1463
|
'总订单金额': ('总订单金额', np.max),
|
1481
1464
|
'总加购数': ('总加购数', np.max),
|
1482
|
-
'下单新客数': ('
|
1465
|
+
'下单新客数': ('下单新客数(去重)', np.max),
|
1483
1466
|
'领券数': ('领券数', np.max),
|
1484
1467
|
'商品关注数': ('商品关注数', np.max),
|
1485
1468
|
'店铺关注数': ('店铺关注数', np.max)
|
@@ -1493,7 +1476,7 @@ class GroupBy:
|
|
1493
1476
|
return df
|
1494
1477
|
elif '天猫店铺来源_手淘搜索' in table_name:
|
1495
1478
|
df = df.groupby(
|
1496
|
-
['日期', '关键词'],
|
1479
|
+
['日期', '关键词', '店铺名称'],
|
1497
1480
|
as_index=False).agg(
|
1498
1481
|
**{
|
1499
1482
|
'访客数': ('访客数', np.max),
|
@@ -1512,7 +1495,7 @@ class GroupBy:
|
|
1512
1495
|
return df
|
1513
1496
|
elif '多店推广场景_按日聚合' in table_name:
|
1514
1497
|
df = df.groupby(
|
1515
|
-
['日期', '
|
1498
|
+
['日期', '店铺名称', '营销场景'],
|
1516
1499
|
as_index=False).agg(
|
1517
1500
|
**{
|
1518
1501
|
'花费': ('花费', np.sum),
|
@@ -1523,7 +1506,7 @@ class GroupBy:
|
|
1523
1506
|
'成交金额': ('成交金额', np.sum)
|
1524
1507
|
}
|
1525
1508
|
)
|
1526
|
-
df.sort_values(['日期', '
|
1509
|
+
df.sort_values(['日期', '店铺名称', '花费'], ascending=[False, False, False], ignore_index=True, inplace=True)
|
1527
1510
|
# df.to_csv('/Users/xigua/Downloads/test.csv', encoding='utf-8_sig', index=False, header=True)
|
1528
1511
|
return df
|
1529
1512
|
elif '达摩盘_人群报表' in table_name:
|
@@ -1835,7 +1818,7 @@ class GroupBy:
|
|
1835
1818
|
break
|
1836
1819
|
return result
|
1837
1820
|
|
1838
|
-
@try_except
|
1821
|
+
# @try_except
|
1839
1822
|
def performance(self, bb_tg=True):
|
1840
1823
|
# print(self.data_tgyj)
|
1841
1824
|
tg, syj, idbm, pic, cost = (
|
@@ -1861,7 +1844,7 @@ class GroupBy:
|
|
1861
1844
|
# 推广表合并生意经 , 以推广数据为基准,销售数据不齐全
|
1862
1845
|
df = pd.merge(df, syj, how='left', left_on=['日期', '商品id'], right_on=['日期', '宝贝id'])
|
1863
1846
|
df.drop(labels='宝贝id', axis=1, inplace=True)
|
1864
|
-
df.drop_duplicates(subset=['日期', '商品id', '花费', '销售额'], keep='last', inplace=True, ignore_index=True)
|
1847
|
+
df.drop_duplicates(subset=['日期', '店铺名称', '商品id', '花费', '销售额'], keep='last', inplace=True, ignore_index=True)
|
1865
1848
|
df.fillna(0, inplace=True)
|
1866
1849
|
df['成本价'] = df['成本价'].astype('float64')
|
1867
1850
|
df['销售额'] = df['销售额'].astype('float64')
|
@@ -2036,7 +2019,7 @@ class GroupBy:
|
|
2036
2019
|
except:
|
2037
2020
|
print(f'{filename}: sort_values排序参数错误!')
|
2038
2021
|
df.to_excel(os.path.join(path, filename + '.xlsx'), index=index, header=header, engine=engine, freeze_panes=freeze_panes)
|
2039
|
-
|
2022
|
+
|
2040
2023
|
|
2041
2024
|
def g_group():
|
2042
2025
|
pass
|
@@ -2120,16 +2103,16 @@ def data_aggregation(service_databases=[{}], months=1, is_juhe=True):
|
|
2120
2103
|
},
|
2121
2104
|
{
|
2122
2105
|
'数据库名': '聚合数据',
|
2123
|
-
'集合名': '
|
2106
|
+
'集合名': '店铺流量来源构成',
|
2124
2107
|
'唯一主键': ['日期', '一级来源', '二级来源', '三级来源', '访客数'],
|
2125
2108
|
'数据主体': sdq.dplyd(),
|
2126
2109
|
},
|
2127
|
-
{
|
2128
|
-
|
2129
|
-
|
2130
|
-
|
2131
|
-
|
2132
|
-
},
|
2110
|
+
# {
|
2111
|
+
# '数据库名': '聚合数据',
|
2112
|
+
# '集合名': '天猫_店铺来源_日数据_旧版',
|
2113
|
+
# '唯一主键': ['日期', '一级来源', '二级来源', '三级来源'],
|
2114
|
+
# '数据主体': sdq.dplyd_old(),
|
2115
|
+
# },
|
2133
2116
|
{
|
2134
2117
|
'数据库名': '聚合数据',
|
2135
2118
|
'集合名': '商品id编码表',
|
@@ -2144,7 +2127,7 @@ def data_aggregation(service_databases=[{}], months=1, is_juhe=True):
|
|
2144
2127
|
},
|
2145
2128
|
{
|
2146
2129
|
'数据库名': '聚合数据',
|
2147
|
-
'集合名': '商品成本',
|
2130
|
+
'集合名': '商品成本', # 暂缺 10.31
|
2148
2131
|
'唯一主键': ['款号'],
|
2149
2132
|
'数据主体': sdq.sp_cost(),
|
2150
2133
|
},
|
@@ -2156,7 +2139,7 @@ def data_aggregation(service_databases=[{}], months=1, is_juhe=True):
|
|
2156
2139
|
},
|
2157
2140
|
{
|
2158
2141
|
'数据库名': '聚合数据',
|
2159
|
-
'集合名': '京东_京准通_全站营销',
|
2142
|
+
'集合名': '京东_京准通_全站营销', # 暂缺
|
2160
2143
|
'唯一主键': ['日期', '产品线', '花费'],
|
2161
2144
|
'数据主体': sdq.jdqzyx(),
|
2162
2145
|
},
|
@@ -2202,18 +2185,18 @@ def data_aggregation(service_databases=[{}], months=1, is_juhe=True):
|
|
2202
2185
|
'唯一主键': ['日期', '报表类型', '推广渠道', '营销场景', '花费'],
|
2203
2186
|
'数据主体': sdq.pxb_zh(),
|
2204
2187
|
},
|
2205
|
-
{
|
2206
|
-
|
2207
|
-
|
2208
|
-
|
2209
|
-
|
2210
|
-
},
|
2211
|
-
{
|
2212
|
-
|
2213
|
-
|
2214
|
-
|
2215
|
-
|
2216
|
-
},
|
2188
|
+
# {
|
2189
|
+
# '数据库名': '聚合数据',
|
2190
|
+
# '集合名': '天猫店铺来源_手淘搜索', # 暂缺
|
2191
|
+
# '唯一主键': ['日期', '关键词', '访客数'],
|
2192
|
+
# '数据主体': sdq.tm_search(),
|
2193
|
+
# },
|
2194
|
+
# {
|
2195
|
+
# '数据库名': '聚合数据',
|
2196
|
+
# '集合名': '生意参谋_直播场次分析', # 暂缺
|
2197
|
+
# '唯一主键': ['场次id'],
|
2198
|
+
# '数据主体': sdq.zb_ccfx(),
|
2199
|
+
# },
|
2217
2200
|
{
|
2218
2201
|
'数据库名': '聚合数据',
|
2219
2202
|
'集合名': '多店推广场景_按日聚合',
|
@@ -2240,8 +2223,8 @@ def data_aggregation(service_databases=[{}], months=1, is_juhe=True):
|
|
2240
2223
|
# 由推广主体报表,写入一个商品索引表,索引规则:从上月 1 号至今花费从高到低排序
|
2241
2224
|
m.df_to_mysql(
|
2242
2225
|
df=g.sp_index_datas,
|
2243
|
-
db_name='属性设置
|
2244
|
-
table_name='商品索引表',
|
2226
|
+
db_name='属性设置3',
|
2227
|
+
table_name='商品索引表_主推排序调用',
|
2245
2228
|
move_insert=False, # 先删除,再插入
|
2246
2229
|
# df_sql=True,
|
2247
2230
|
drop_duplicates=False,
|
@@ -2327,6 +2310,6 @@ def main():
|
|
2327
2310
|
|
2328
2311
|
|
2329
2312
|
if __name__ == '__main__':
|
2330
|
-
data_aggregation(service_databases=[{'company': 'mysql'}], months=0, is_juhe=
|
2313
|
+
data_aggregation(service_databases=[{'company': 'mysql'}], months=0, is_juhe=True) # 正常的聚合所有数据
|
2331
2314
|
# data_aggregation_one(service_databases=[{'company': 'mysql'}], months=1) # 单独聚合某一个数据库,具体库进函数编辑
|
2332
2315
|
# optimize_data.op_data(service_databases=[{'company': 'mysql'}], days=3650) # 立即启动对聚合数据的清理工作
|
@@ -98,21 +98,6 @@ class DataClean:
|
|
98
98
|
'数据库名': '生意参谋3',
|
99
99
|
'集合名称': '店铺流量来源构成',
|
100
100
|
},
|
101
|
-
{
|
102
|
-
'文件简称': '商品类目属性_', # 文件名中包含的字符
|
103
|
-
'数据库名': '生意参谋3',
|
104
|
-
'集合名称': '商品类目属性',
|
105
|
-
},
|
106
|
-
{
|
107
|
-
'文件简称': '商品主图视频_', # 文件名中包含的字符
|
108
|
-
'数据库名': '生意参谋3',
|
109
|
-
'集合名称': '商品主图视频',
|
110
|
-
},
|
111
|
-
{
|
112
|
-
'文件简称': '商品sku属性_', # 文件名中包含的字符
|
113
|
-
'数据库名': '生意参谋3',
|
114
|
-
'集合名称': '商品sku',
|
115
|
-
},
|
116
101
|
]
|
117
102
|
for root, dirs, files in os.walk(path, topdown=False):
|
118
103
|
for name in files:
|
@@ -160,10 +145,6 @@ class DataClean:
|
|
160
145
|
new_name = f'py_xg_{os.path.splitext(name)[0]}.csv'
|
161
146
|
self.save_to_csv(df, root, new_name, encoding='utf-8_sig')
|
162
147
|
os.remove(os.path.join(root, name))
|
163
|
-
elif name.endswith('.csv') and ('商品类目属性' in name or '商品主图视频' in name or '商品sku属性' in name):
|
164
|
-
df = pd.read_csv(os.path.join(root, name), encoding='utf-8_sig', header=0, na_filter=False)
|
165
|
-
new_name = f'py_xg_{os.path.splitext(name)[0]}.csv'
|
166
|
-
os.rename(os.path.join(root, name), os.path.join(root, new_name))
|
167
148
|
|
168
149
|
# 将数据传入 self.datas 等待更新进数据库
|
169
150
|
if not db_name or not collection_name:
|
@@ -245,67 +226,67 @@ class DataClean:
|
|
245
226
|
report_names = [
|
246
227
|
{
|
247
228
|
'文件简称': 'tg_report_主体报表',
|
248
|
-
'数据库名': '推广数据
|
229
|
+
'数据库名': '推广数据2',
|
249
230
|
'集合名称': '主体报表',
|
250
231
|
},
|
251
232
|
{
|
252
233
|
'文件简称': 'tg_report_创意报表_创意',
|
253
|
-
'数据库名': '推广数据
|
234
|
+
'数据库名': '推广数据2',
|
254
235
|
'集合名称': '创意报表_创意',
|
255
236
|
},
|
256
237
|
{
|
257
238
|
'文件简称': 'tg_report_创意报表_素材',
|
258
|
-
'数据库名': '推广数据
|
239
|
+
'数据库名': '推广数据2',
|
259
240
|
'集合名称': '创意报表_素材',
|
260
241
|
},
|
261
242
|
{
|
262
243
|
'文件简称': 'tg_report_单元报表',
|
263
|
-
'数据库名': '推广数据
|
244
|
+
'数据库名': '推广数据2',
|
264
245
|
'集合名称': '单元报表',
|
265
246
|
},
|
266
247
|
{
|
267
248
|
'文件简称': 'tg_report_地域报表_省份',
|
268
|
-
'数据库名': '推广数据
|
249
|
+
'数据库名': '推广数据2',
|
269
250
|
'集合名称': '地域报表_省份',
|
270
251
|
},
|
271
252
|
{
|
272
253
|
'文件简称': 'tg_report_地域报表_城市',
|
273
|
-
'数据库名': '推广数据
|
254
|
+
'数据库名': '推广数据2',
|
274
255
|
'集合名称': '地域报表_城市',
|
275
256
|
},
|
276
257
|
{
|
277
258
|
'文件简称': 'tg_report_关键词报表',
|
278
|
-
'数据库名': '推广数据
|
259
|
+
'数据库名': '推广数据2',
|
279
260
|
'集合名称': '关键词报表',
|
280
261
|
},
|
281
262
|
{
|
282
263
|
'文件简称': 'tg_report_计划报表',
|
283
|
-
'数据库名': '推广数据
|
264
|
+
'数据库名': '推广数据2',
|
284
265
|
'集合名称': '计划报表',
|
285
266
|
},
|
286
267
|
{
|
287
268
|
'文件简称': 'tg_report_权益报表',
|
288
|
-
'数据库名': '推广数据
|
269
|
+
'数据库名': '推广数据2',
|
289
270
|
'集合名称': '权益报表',
|
290
271
|
},
|
291
272
|
{
|
292
273
|
'文件简称': 'tg_report_人群报表',
|
293
|
-
'数据库名': '推广数据
|
274
|
+
'数据库名': '推广数据2',
|
294
275
|
'集合名称': '人群报表',
|
295
276
|
},
|
296
277
|
{
|
297
278
|
'文件简称': 'tg_report_营销场景报表',
|
298
|
-
'数据库名': '推广数据
|
279
|
+
'数据库名': '推广数据2',
|
299
280
|
'集合名称': '营销场景报表',
|
300
281
|
},
|
301
282
|
{
|
302
283
|
'文件简称': 'tg_report_超级直播报表_人群',
|
303
|
-
'数据库名': '推广数据
|
284
|
+
'数据库名': '推广数据2',
|
304
285
|
'集合名称': '超级直播',
|
305
286
|
},
|
306
287
|
{
|
307
288
|
'文件简称': 'tg_report_品销宝_明星店铺',
|
308
|
-
'数据库名': '推广数据
|
289
|
+
'数据库名': '推广数据2',
|
309
290
|
'集合名称': '品销宝',
|
310
291
|
}
|
311
292
|
]
|
@@ -338,9 +319,9 @@ class DataClean:
|
|
338
319
|
continue
|
339
320
|
# 区分淘宝和天猫的报表
|
340
321
|
if '万里马官方旗舰店' in name:
|
341
|
-
|
322
|
+
pass
|
342
323
|
elif '万里马官方企业店' in name:
|
343
|
-
db_name =
|
324
|
+
db_name = '推广数据_淘宝店'
|
344
325
|
else:
|
345
326
|
print(f'报表名称错误,不属于天猫/淘宝店:{name}')
|
346
327
|
continue
|
@@ -407,22 +388,22 @@ class DataClean:
|
|
407
388
|
report_names = [
|
408
389
|
{
|
409
390
|
'文件简称': 'baobei',
|
410
|
-
'数据库名': '
|
391
|
+
'数据库名': '生意经2',
|
411
392
|
'集合名称': '宝贝指标',
|
412
393
|
},
|
413
394
|
{
|
414
395
|
'文件简称': 'order',
|
415
|
-
'数据库名': '
|
396
|
+
'数据库名': '生意经2',
|
416
397
|
'集合名称': '订单指标',
|
417
398
|
},
|
418
399
|
{
|
419
400
|
'文件简称': '省份城市分析',
|
420
|
-
'数据库名': '
|
401
|
+
'数据库名': '生意经2',
|
421
402
|
'集合名称': '省份城市分析',
|
422
403
|
},
|
423
404
|
{
|
424
405
|
'文件简称': '店铺销售指标',
|
425
|
-
'数据库名': '
|
406
|
+
'数据库名': '生意经2',
|
426
407
|
'集合名称': '店铺销售指标',
|
427
408
|
},
|
428
409
|
]
|
@@ -803,6 +784,29 @@ class DataClean:
|
|
803
784
|
def sp_scene_clean(self, path=None, is_except=[]):
|
804
785
|
if not path:
|
805
786
|
path = self.path
|
787
|
+
report_names = [
|
788
|
+
{
|
789
|
+
'文件简称': '商品素材_', # 文件名中包含的字符
|
790
|
+
'数据库名': '属性设置3',
|
791
|
+
'集合名称': '商品素材中心',
|
792
|
+
},
|
793
|
+
{
|
794
|
+
'文件简称': '商品类目属性_', # 文件名中包含的字符
|
795
|
+
'数据库名': '属性设置3',
|
796
|
+
'集合名称': '商品类目属性',
|
797
|
+
},
|
798
|
+
{
|
799
|
+
'文件简称': '商品主图视频_', # 文件名中包含的字符
|
800
|
+
'数据库名': '属性设置3',
|
801
|
+
'集合名称': '商品主图视频',
|
802
|
+
},
|
803
|
+
{
|
804
|
+
'文件简称': '商品sku属性_', # 文件名中包含的字符
|
805
|
+
'数据库名': '属性设置3',
|
806
|
+
'集合名称': '商品sku',
|
807
|
+
},
|
808
|
+
]
|
809
|
+
|
806
810
|
for root, dirs, files in os.walk(path, topdown=False):
|
807
811
|
for name in files:
|
808
812
|
if '~$' in name or '.DS' in name or '.localized' in name or '.jpg' in name or '.png' in name:
|
@@ -820,18 +824,29 @@ class DataClean:
|
|
820
824
|
continue
|
821
825
|
db_name = None # 初始化参数
|
822
826
|
collection_name = None
|
827
|
+
for item in report_names:
|
828
|
+
if item['文件简称'] in name:
|
829
|
+
db_name = item['数据库名']
|
830
|
+
collection_name = item['集合名称']
|
831
|
+
is_continue = True
|
832
|
+
if not is_continue:
|
833
|
+
continue
|
823
834
|
|
824
835
|
if name.endswith('.xlsx') and '商品素材_' in name:
|
825
836
|
shop_name = re.findall(r'_([\u4e00-\u9fffA-Za-z]+店)_', name)[0]
|
826
837
|
df = pd.read_excel(os.path.join(root, name), header=0)
|
838
|
+
if '日期' not in df.columns.tolist():
|
839
|
+
df.insert(loc=0, column='日期', value=datetime.datetime.today().strftime('%Y-%m-%d'))
|
827
840
|
if '店铺名称' not in df.columns.tolist():
|
828
841
|
df.insert(loc=1, column='店铺名称', value=shop_name)
|
829
842
|
new_name = f'py_xg_{name}'
|
830
843
|
df.to_excel(os.path.join(upload_path, new_name),
|
831
844
|
index=False, header=True, engine='openpyxl', freeze_panes=(1, 0))
|
832
|
-
db_name = '属性设置3'
|
833
|
-
collection_name = '商品素材'
|
834
845
|
os.remove(os.path.join(root, name))
|
846
|
+
elif name.endswith('.csv') and ('商品类目属性' in name or '商品主图视频' in name or '商品sku属性' in name):
|
847
|
+
df = pd.read_csv(os.path.join(root, name), encoding='utf-8_sig', header=0, na_filter=False)
|
848
|
+
new_name = f'py_xg_{os.path.splitext(name)[0]}.csv'
|
849
|
+
os.rename(os.path.join(root, name), os.path.join(root, new_name))
|
835
850
|
|
836
851
|
# 将数据传入 self.datas 等待更新进数据库
|
837
852
|
if not db_name or not collection_name:
|
@@ -936,7 +951,7 @@ class DataClean:
|
|
936
951
|
continue
|
937
952
|
|
938
953
|
if name.endswith('.csv') and '人群属性_万里马官方旗舰店' in name:
|
939
|
-
t_path = os.path.join(self.source_path, '
|
954
|
+
t_path = os.path.join(self.source_path, '达摩盘', '我的人群属性')
|
940
955
|
bib(t_path, _as_month=True)
|
941
956
|
|
942
957
|
|
@@ -1364,6 +1379,51 @@ class DataClean:
|
|
1364
1379
|
df_to_json.as_json_file() # 写入 json 文件, 包含数据的 dtypes 信息
|
1365
1380
|
|
1366
1381
|
|
1382
|
+
def test():
|
1383
|
+
# main_key = '单元报表'
|
1384
|
+
path = f'/Users/xigua/数据中心/原始文件3/天猫推广报表/主体报表'
|
1385
|
+
for root, dirs, files in os.walk(path, topdown=False):
|
1386
|
+
for name in files:
|
1387
|
+
if '~$' in name or '.DS' in name or '.localized' in name or '.jpg' in name or '.png' in name:
|
1388
|
+
continue
|
1389
|
+
# if 'py_xg' in name:
|
1390
|
+
# continue
|
1391
|
+
# if 'TM_旧表_字段' in root:
|
1392
|
+
# continue
|
1393
|
+
|
1394
|
+
if name.endswith('.csv'):
|
1395
|
+
print(name)
|
1396
|
+
df = pd.read_csv(os.path.join(root, name), encoding='utf-8_sig', header=0, na_filter=False)
|
1397
|
+
# if '店铺名称' not in df.columns.tolist():
|
1398
|
+
# df.insert(loc=1, column='店铺名称', value='万里马官方旗舰店')
|
1399
|
+
# df.replace(to_replace=['-'], value=0, regex=False, inplace=True)
|
1400
|
+
# df.replace(to_replace=[','], value='', regex=True, inplace=True)
|
1401
|
+
# if '统计日期' in df.columns.tolist() and '日期' not in df.columns.tolist():
|
1402
|
+
# df.rename(columns={'统计日期': '日期', '商品ID': '商品id'}, inplace=True)
|
1403
|
+
# shop_name = re.findall(r'_([\u4e00-\u9fffA-Za-z]+店)', name)[0]
|
1404
|
+
# df.insert(loc=1, column='店铺名称', value=shop_name)
|
1405
|
+
|
1406
|
+
date_all = re.findall(r'_(\d{4}-\d{2}-\d{2})_', name)[0]
|
1407
|
+
|
1408
|
+
date = re.findall(r'_(\d{4}-\d{2})-\d{2}', name)[0]
|
1409
|
+
|
1410
|
+
new_path = f'/Users/xigua/数据中心/原始文件3/天猫_生意参谋/商品排行/{date}'
|
1411
|
+
# new_path = os.path.join(new_path, date) # 添加 年月分类
|
1412
|
+
if not os.path.exists(new_path):
|
1413
|
+
os.makedirs(new_path, exist_ok=True)
|
1414
|
+
# print(date_all)
|
1415
|
+
|
1416
|
+
new_name = f'py_xg_商品排行_万里马官方旗舰店_{date_all}.csv'
|
1417
|
+
# print(os.path.join(new_path, new_name))
|
1418
|
+
# breakpoint()
|
1419
|
+
df.to_csv(os.path.join(new_path, new_name), encoding='utf-8_sig', index=False, header=True)
|
1420
|
+
# try:
|
1421
|
+
# df.to_excel(os.path.join(new_path, new_name),
|
1422
|
+
# index=False, header=True, engine='openpyxl', freeze_panes=(1, 0))
|
1423
|
+
# except Exception as e:
|
1424
|
+
# print(e)
|
1425
|
+
|
1426
|
+
|
1367
1427
|
def main(service_databases=None, is_mysql=False):
|
1368
1428
|
"""
|
1369
1429
|
is_mysql: 调试时加,False: 是否后续的聚合数据
|
@@ -1410,20 +1470,16 @@ def main(service_databases=None, is_mysql=False):
|
|
1410
1470
|
# 清理所有非聚合数据的库
|
1411
1471
|
optimize_data.op_data(
|
1412
1472
|
db_name_lists=[
|
1413
|
-
'京东数据
|
1473
|
+
'京东数据3',
|
1474
|
+
'属性设置3',
|
1414
1475
|
'推广数据2',
|
1415
|
-
'
|
1416
|
-
'
|
1476
|
+
'生意参谋3',
|
1477
|
+
'推广数据_淘宝店',
|
1478
|
+
'爱库存2'
|
1479
|
+
'生意参谋3',
|
1417
1480
|
'生意经2',
|
1418
|
-
'属性设置2',
|
1419
1481
|
# '聚合数据', # 不在这里清理聚合数据, 还未开始聚合呢
|
1420
|
-
'
|
1421
|
-
'天猫_推广数据3',
|
1422
|
-
'淘宝_推广数据3',
|
1423
|
-
# '市场数据3',
|
1424
|
-
'生意参谋3',
|
1425
|
-
'天猫_生意经3',
|
1426
|
-
# '淘宝_生意经3',
|
1482
|
+
'达摩盘3',
|
1427
1483
|
],
|
1428
1484
|
days=100,
|
1429
1485
|
is_mongo=True,
|
@@ -1445,53 +1501,6 @@ def main(service_databases=None, is_mysql=False):
|
|
1445
1501
|
)
|
1446
1502
|
|
1447
1503
|
|
1448
|
-
def test():
|
1449
|
-
# main_key = '单元报表'
|
1450
|
-
path = f'/Users/xigua/数据中心/原始文件3/天猫推广报表/主体报表'
|
1451
|
-
for root, dirs, files in os.walk(path, topdown=False):
|
1452
|
-
for name in files:
|
1453
|
-
if '~$' in name or '.DS' in name or '.localized' in name or '.jpg' in name or '.png' in name:
|
1454
|
-
continue
|
1455
|
-
# if 'py_xg' in name:
|
1456
|
-
# continue
|
1457
|
-
# if 'TM_旧表_字段' in root:
|
1458
|
-
# continue
|
1459
|
-
|
1460
|
-
if name.endswith('.csv'):
|
1461
|
-
print(name)
|
1462
|
-
df = pd.read_csv(os.path.join(root, name), encoding='utf-8_sig', header=0, na_filter=False)
|
1463
|
-
# if '店铺名称' not in df.columns.tolist():
|
1464
|
-
# df.insert(loc=1, column='店铺名称', value='万里马官方旗舰店')
|
1465
|
-
# df.replace(to_replace=['-'], value=0, regex=False, inplace=True)
|
1466
|
-
# df.replace(to_replace=[','], value='', regex=True, inplace=True)
|
1467
|
-
# if '统计日期' in df.columns.tolist() and '日期' not in df.columns.tolist():
|
1468
|
-
# df.rename(columns={'统计日期': '日期', '商品ID': '商品id'}, inplace=True)
|
1469
|
-
# shop_name = re.findall(r'_([\u4e00-\u9fffA-Za-z]+店)', name)[0]
|
1470
|
-
# df.insert(loc=1, column='店铺名称', value=shop_name)
|
1471
|
-
|
1472
|
-
date_all = re.findall(r'_(\d{4}-\d{2}-\d{2})_', name)[0]
|
1473
|
-
|
1474
|
-
date = re.findall(r'_(\d{4}-\d{2})-\d{2}', name)[0]
|
1475
|
-
|
1476
|
-
new_path = f'/Users/xigua/数据中心/原始文件3/天猫_生意参谋/商品排行/{date}'
|
1477
|
-
# new_path = os.path.join(new_path, date) # 添加 年月分类
|
1478
|
-
if not os.path.exists(new_path):
|
1479
|
-
os.makedirs(new_path, exist_ok=True)
|
1480
|
-
# print(date_all)
|
1481
|
-
|
1482
|
-
new_name = f'py_xg_商品排行_万里马官方旗舰店_{date_all}.csv'
|
1483
|
-
# print(os.path.join(new_path, new_name))
|
1484
|
-
# breakpoint()
|
1485
|
-
df.to_csv(os.path.join(new_path, new_name), encoding='utf-8_sig', index=False, header=True)
|
1486
|
-
# try:
|
1487
|
-
# df.to_excel(os.path.join(new_path, new_name),
|
1488
|
-
# index=False, header=True, engine='openpyxl', freeze_panes=(1, 0))
|
1489
|
-
# except Exception as e:
|
1490
|
-
# print(e)
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
1504
|
if __name__ == '__main__':
|
1496
1505
|
main(
|
1497
1506
|
service_databases = [
|
@@ -1500,7 +1509,7 @@ if __name__ == '__main__':
|
|
1500
1509
|
# {'home_lx': 'mongodb'},
|
1501
1510
|
# {'nas': 'mysql'},
|
1502
1511
|
],
|
1503
|
-
is_mysql = False,
|
1512
|
+
is_mysql = False, # 清理聚合数据
|
1504
1513
|
)
|
1505
1514
|
|
1506
1515
|
# c = DataClean(
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|