mesa/测试数据 产品通编码.py

26 lines
704 B
Python
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.

import pandas as pd
import numpy as np
# 设置数据行数
total_rows = 106 # 总共100行
material_count = 50 # 前61行为材料
# 生成产品id
product_ids = np.arange(1, total_rows + 1)
# 生成种类前70行是材料后面是设备
categories = ['材料'] * material_count + ['设备'] * (total_rows - material_count)
# 创建数据框
df_products = pd.DataFrame({
'产品id': product_ids,
'种类': categories
})
# 保存为CSV文件
file_path_products = '测试数据 products_materials_equipment.csv'
df_products.to_csv(file_path_products, index=False) # index=False 不保存行索引
# 打印文件路径
print(f"CSV 文件已生成,路径为: {file_path_products}")