2024-09-20 09:26:39 +08:00
|
|
|
|
import pandas as pd
|
|
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
|
|
# 设置随机种子以确保结果可重复
|
|
|
|
|
np.random.seed(42)
|
|
|
|
|
|
|
|
|
|
# 定义行数,即生成多少个设备
|
2024-09-21 22:39:09 +08:00
|
|
|
|
num_rows = 56
|
2024-09-20 09:26:39 +08:00
|
|
|
|
|
|
|
|
|
# 生成设备id(例如100到200之间的设备ID)
|
2024-09-21 22:39:09 +08:00
|
|
|
|
device_ids = (i for i in range(51, 107))
|
2024-09-20 09:26:39 +08:00
|
|
|
|
|
|
|
|
|
# 生成设备残值,假设范围在1000到10000之间
|
|
|
|
|
device_salvage_values = np.random.randint(10, 1000, size=num_rows)
|
|
|
|
|
|
|
|
|
|
# 创建数据框,将设备id和设备残值结合起来
|
|
|
|
|
df_devices = pd.DataFrame({
|
|
|
|
|
'设备id': device_ids,
|
|
|
|
|
'设备残值': device_salvage_values
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
# 保存为CSV文件
|
|
|
|
|
file_path_devices = '测试数据 device_salvage_values.csv'
|
|
|
|
|
df_devices.to_csv(file_path_devices, index=False)
|