ngv中g转化率改为保留三位小数

This commit is contained in:
z66
2025-12-11 09:13:14 +08:00
parent 262d443b5c
commit 42da18e929
9 changed files with 188 additions and 223 deletions
+8
View File
@@ -0,0 +1,8 @@
2025-12-10 17:16:02,131 - log_config.py - error_task_logger - ERROR - NGV更新数据执行时发生异常: name 'data_NGV_j' is not defined
Traceback (most recent call last):
File "D:\Idea Project\SaaS_V1.7\back_ground_module\update_all_NGV_data_daily.py", line 106, in main
prepared_data = self._prepare_data_for_sync(changed_data, staff_id_map)
File "D:\Idea Project\SaaS_V1.7\back_ground_module\update_all_NGV_data_daily.py", line 561, in _prepare_data_for_sync
prepared_df['g_month_percentage'] = (pd.to_numeric(data_NGV_j['g_month_percentage'], errors='coerce')
^^^^^^^^^^
NameError: name 'data_NGV_j' is not defined
+5
View File
@@ -110,6 +110,11 @@ class UpdateNGVData:
filtered_df[col + "_staff_id"] = staff_ids
logger.info(f"人员转换完成")
# 数字保留3位小数
filtered_df['g_month_percentage'] = (pd.to_numeric(data_NGV_j['g_month_percentage'], errors='coerce')
.round(3)
.apply(lambda x: f"{x:.3f}" if pd.notna(x) else ''))
# filtered_df.to_csv(r"D:\Idea Project\SaaS_V1.3\back_ground_module\output\NGV.csv")
# 生成包含所有行转换后的字典列表
@@ -557,6 +557,12 @@ class UpdateAllNGVDataDaily:
logger.info(" - 人员字段已转换为员工ID")
# 5.3G转化率保留3位小数
prepared_df['g_month_percentage'] = (pd.to_numeric(prepared_df['g_month_percentage'], errors='coerce')
.round(3)
.apply(lambda x: f"{x:.3f}" if pd.notna(x) else ''))
logger.info(" - G转化率已保留3位小数")
return prepared_df
def _sync_to_jiandaoyun(self, data_df):