import pandas as pd import numpy as np # 设置随机种子 np.random.seed(42) # 生成企业和设备数据 num_rows = 10 # 每个表的行数 # 构造数据 company_ids = np.random.randint(1000, 1100, size=num_rows) device_ids = np.random.randint(100, 200, size=num_rows) material_ids = np.random.randint(0, 100, size=num_rows) product_ids = np.random.randint(0, 200, size=num_rows) device_quantities = np.random.randint(50, 200, size=num_rows) material_quantities = np.random.randint(100,200, size=num_rows) product_quantities = np.random.randint(20, 100, size=num_rows) # 创建三个表格的数据框 df_devices = pd.DataFrame({ '企业id': company_ids, '设备id': device_ids, '设备数量': device_quantities }) df_materials = pd.DataFrame({ '企业id': company_ids, '材料id': material_ids, '材料数量': material_quantities }) df_products = pd.DataFrame({ '企业id': company_ids, '产品id': product_ids, '产品数量': product_quantities }) # 保存为CSV文件 df_devices.to_csv('测试数据 companies_devices.csv', index=False) df_materials.to_csv('测试数据 companies_materials.csv', index=False) df_products.to_csv('测试数据 companies_products.csv', index=False)