Commit 1ec3ece6 authored by 邱阿朋's avatar 邱阿朋

fix(vc): 修复退货订单总金额处理异常

- 优化 Total amount 列的数据处理逻辑
- 先将数据转换为字符串,再移除逗号并替换 nan 为 None
- 使用 pd.to_numeric 转换为数值型,无法转换的值设为 NaN
- 提高了数据处理的健壮性和准确性
parent 8af1290c
......@@ -73,7 +73,9 @@ class ReturnGoods(AutoInterface):
self.logger.warning(f"{return_id} 订单详情读取失败")
continue
item_data['Total amount'] = item_data['Total amount'].str.replace(',', '').astype(float)
item_data['Total amount'] = item_data['Total amount'].astype(str).str.replace(',', '').replace('nan', None)
item_data['Total amount'] = pd.to_numeric(item_data['Total amount'], errors='coerce')
# 按 'Purchase order' 和 'ASIN' 分组,并对 'Quantity' 和 Total amount 进行求和
item_data_result = item_data.groupby(['Purchase order', 'ASIN', 'Reason'], as_index=False).agg({
'Quantity': 'sum',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment