mdbq 3.3.16__py3-none-any.whl → 3.4.0__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 +13 -10
- mdbq/mysql/mysql.py +4 -0
- {mdbq-3.3.16.dist-info → mdbq-3.4.0.dist-info}/METADATA +1 -1
- {mdbq-3.3.16.dist-info → mdbq-3.4.0.dist-info}/RECORD +6 -6
- {mdbq-3.3.16.dist-info → mdbq-3.4.0.dist-info}/WHEEL +0 -0
- {mdbq-3.3.16.dist-info → mdbq-3.4.0.dist-info}/top_level.txt +0 -0
mdbq/aggregation/query_data.py
CHANGED
@@ -495,17 +495,19 @@ class MysqlDatasQuery:
|
|
495
495
|
df_sx.rename(columns={'消费能力等级': '消费力层级'}, inplace=True)
|
496
496
|
df = pd.merge(df, df_sx, left_on=['人群名字'], right_on=['人群名称'], how='left')
|
497
497
|
df.pop('人群名称')
|
498
|
-
df['消费力层级'] = df['消费力层级'].apply(
|
499
|
-
|
498
|
+
df['消费力层级'] = df['消费力层级'].apply(
|
499
|
+
lambda x: f'L{"".join(re.findall(r'L(\d)', str(x)))}' if str(x) != 'nan' else x)
|
500
|
+
df['用户年龄'] = df['用户年龄'].apply(
|
501
|
+
lambda x: "~".join(re.findall(r'(\d{2})\D.*(\d{2})岁', str(x))[0])
|
502
|
+
if str(x) != 'nan' and re.findall(r'(\d{2})\D.*(\d{2})岁', str(x)) else x)
|
500
503
|
|
501
504
|
# 1. 匹配 L后面接 2 个或以上数字,不区分大小写,示例:L345
|
502
505
|
# 2. 其余情况,L 后面接多个数字的都会被第一条 if 命中,不区分大小写
|
503
506
|
|
504
507
|
df['消费力层级'] = df.apply(
|
505
508
|
lambda x:
|
506
|
-
''.join(re.findall(r'(l\d+)', x['人群名字'].upper(), re.IGNORECASE))
|
507
|
-
|
508
|
-
re.IGNORECASE) and str(x['消费力层级']) == 'nan'
|
509
|
+
''.join(re.findall(r'(l\d+)', x['人群名字'].upper(), re.IGNORECASE))
|
510
|
+
if re.findall(r'(l\d{2,})', x['人群名字'], re.IGNORECASE) and str(x['消费力层级']) == 'nan'
|
509
511
|
else 'L5' if re.findall(r'(l\d*5)', x['人群名字'], re.IGNORECASE) and str(x['消费力层级']) == 'nan'
|
510
512
|
else 'L4' if re.findall(r'(l\d*4)', x['人群名字'], re.IGNORECASE) and str(x['消费力层级']) == 'nan'
|
511
513
|
else 'L3' if re.findall(r'(l\d*3)', x['人群名字'], re.IGNORECASE) and str(x['消费力层级']) == 'nan'
|
@@ -524,11 +526,12 @@ class MysqlDatasQuery:
|
|
524
526
|
pattern2 = r'(?<![\dlL])(\d{2}_\d{2})'
|
525
527
|
df['用户年龄'] = df.apply(
|
526
528
|
lambda x:
|
527
|
-
''.join(re.findall(pattern1, x['人群名字'].upper()))
|
528
|
-
|
529
|
-
else ''.join(re.findall(pattern2, x['人群名字'].upper()))
|
530
|
-
|
531
|
-
|
529
|
+
''.join(re.findall(pattern1, x['人群名字'].upper()))
|
530
|
+
if re.findall(pattern1, x['人群名字']) and str(x['用户年龄']) == 'nan'
|
531
|
+
else ''.join(re.findall(pattern2, x['人群名字'].upper()))
|
532
|
+
if re.findall(pattern2, x['人群名字']) and str(x['用户年龄']) == 'nan'
|
533
|
+
else ''.join(re.findall(r'(\d{2}-\d{2})岁', x['人群名字'].upper()))
|
534
|
+
if re.findall(r'(\d{2}-\d{2})岁', x['人群名字']) and str(x['用户年龄']) == 'nan'
|
532
535
|
else x['用户年龄'], axis=1)
|
533
536
|
df['用户年龄'] = df['用户年龄'].apply(
|
534
537
|
lambda x: f'{x[:2]}~{x[2:4]}' if str(x).isdigit()
|
mdbq/mysql/mysql.py
CHANGED
@@ -113,6 +113,7 @@ class MysqlUpload:
|
|
113
113
|
|
114
114
|
@staticmethod
|
115
115
|
def try_except(func): # 在类内部定义一个异常处理方法
|
116
|
+
|
116
117
|
@wraps(func)
|
117
118
|
def wrapper(*args, **kwargs):
|
118
119
|
try:
|
@@ -122,6 +123,7 @@ class MysqlUpload:
|
|
122
123
|
with open(error_file, 'a') as f:
|
123
124
|
now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
124
125
|
f.write(f'\n{now} \n')
|
126
|
+
f.write(f'函数注释内容(用于定位函数): {func.__doc__} \n')
|
125
127
|
# f.write(f'报错的文件:\n{e.__traceback__.tb_frame.f_globals["__file__"]}\n') # 发生异常所在的文件
|
126
128
|
traceback.print_exc(file=open(error_file, 'a')) # 返回完整的堆栈信息
|
127
129
|
print(f'更多信息请查看日志文件: {error_file}')
|
@@ -1439,6 +1441,7 @@ class OptimizeDatas:
|
|
1439
1441
|
|
1440
1442
|
@staticmethod
|
1441
1443
|
def try_except(func): # 在类内部定义一个异常处理方法
|
1444
|
+
|
1442
1445
|
@wraps(func)
|
1443
1446
|
def wrapper(*args, **kwargs):
|
1444
1447
|
try:
|
@@ -1448,6 +1451,7 @@ class OptimizeDatas:
|
|
1448
1451
|
with open(error_file, 'a') as f:
|
1449
1452
|
now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
1450
1453
|
f.write(f'\n{now} \n')
|
1454
|
+
f.write(f'函数注释内容(用于定位函数): {func.__doc__} \n')
|
1451
1455
|
# f.write(f'报错的文件:\n{e.__traceback__.tb_frame.f_globals["__file__"]}\n') # 发生异常所在的文件
|
1452
1456
|
traceback.print_exc(file=open(error_file, 'a')) # 返回完整的堆栈信息
|
1453
1457
|
print(f'更多信息请查看日志文件: {error_file}')
|
@@ -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=2NzHGjGoUy2WG-MxmbilCj6KBAmVah3jqFuEd2zv9XU,32379
|
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=FiNZhL5_El2B5ADfCPGUZXsE2iZd3UmGml9Te9qJIpU,175364
|
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
|
@@ -18,7 +18,7 @@ mdbq/log/mylogger.py,sha256=oaT7Bp-Hb9jZt52seP3ISUuxVcI19s4UiqTeouScBO0,3258
|
|
18
18
|
mdbq/mongo/__init__.py,sha256=SILt7xMtQIQl_m-ik9WLtJSXIVf424iYgCfE_tnQFbw,13
|
19
19
|
mdbq/mongo/mongo.py,sha256=M9DUeUCMPDngkwn9-ui0uTiFrvfNU1kLs22s5SmoNm0,31899
|
20
20
|
mdbq/mysql/__init__.py,sha256=A_DPJyAoEvTSFojiI2e94zP0FKtCkkwKP1kYUCSyQzo,11
|
21
|
-
mdbq/mysql/mysql.py,sha256=
|
21
|
+
mdbq/mysql/mysql.py,sha256=r5YkS1WnV9dGtEHFcwaekjtUBgFcvkdmwif-m52CyHI,99560
|
22
22
|
mdbq/mysql/recheck_mysql.py,sha256=ppBTfBLgkRWirMVZ31e_ZPULiGPJU7K3PP9G6QBZ3QI,8605
|
23
23
|
mdbq/mysql/s_query.py,sha256=6L5Cp90zq13noZHjzSA5mqms_hD01c8GO1_NfbYDu6w,9252
|
24
24
|
mdbq/mysql/year_month_day.py,sha256=VgewoE2pJxK7ErjfviL_SMTN77ki8GVbTUcao3vFUCE,1523
|
@@ -34,7 +34,7 @@ mdbq/pbix/refresh_all.py,sha256=OBT9EewSZ0aRS9vL_FflVn74d4l2G00wzHiikCC4TC0,5926
|
|
34
34
|
mdbq/pbix/refresh_all_old.py,sha256=_pq3WSQ728GPtEG5pfsZI2uTJhU8D6ra-htIk1JXYzw,7192
|
35
35
|
mdbq/spider/__init__.py,sha256=RBMFXGy_jd1HXZhngB2T2XTvJqki8P_Fr-pBcwijnew,18
|
36
36
|
mdbq/spider/aikucun.py,sha256=eAIITxnbbxsR_EoohJ78CRw2dEdfSHOltfpxBrh0cvc,22207
|
37
|
-
mdbq-3.
|
38
|
-
mdbq-3.
|
39
|
-
mdbq-3.
|
40
|
-
mdbq-3.
|
37
|
+
mdbq-3.4.0.dist-info/METADATA,sha256=5yMS8KxK8EkUCkrPLlPexLMSb2JYk3pVTL5b2S39uME,243
|
38
|
+
mdbq-3.4.0.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
39
|
+
mdbq-3.4.0.dist-info/top_level.txt,sha256=2FQ-uLnCSB-OwFiWntzmwosW3X2Xqsg0ewh1axsaylA,5
|
40
|
+
mdbq-3.4.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|