25 lines
677 B
Python
25 lines
677 B
Python
import pandas as pd
|
||
import numpy as np
|
||
|
||
# 设置随机种子以确保结果可重复
|
||
np.random.seed(42)
|
||
|
||
# 定义行数,即生成多少个设备
|
||
num_rows = 56
|
||
|
||
# 生成设备id(例如100到200之间的设备ID)
|
||
device_ids = (i for i in range(51, 107))
|
||
|
||
# 生成设备残值,假设范围在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)
|