logistics/产品上限优化.ipynb

70 lines
1.8 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"df = pd.read_clipboard()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"得到每个SKU的最长边围长总重量6000抛重采购体积比采购/6000抛重"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import re\n",
"from utils import Package,Package_group\n",
"def extract_number(value):\n",
" # 提取字符串中的第一个数字\n",
" match = re.search(r\"[-+]?\\d*\\.\\d+|\\d+\", str(value))\n",
" return float(match.group()) if match else 0.0\n",
"for index, row in df.iterrows():\n",
" package_dict = json.loads(row['erp_package_vol'])\n",
" max_length = 0 # 最长边\n",
" max_girth = 0 # 最大围长\n",
" all_weight = 0 # 总重量\n",
" all_vol_weight = 0 # 总抛重\n",
" for key, package in package_dict.items():\n",
" package['长'] = extract_number(package['长'])\n",
" package['宽'] = extract_number(package['宽'])\n",
" package['高'] = extract_number(package['高'])\n",
" package['重量'] = extract_number(package['重量'])\n",
" "
]
}
],
"metadata": {
"kernelspec": {
"display_name": "base",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}