我有以下格式的时间戳列表: 2018-23-01
我从八月到八月每五分钟生成一次时间戳记。该生成是自动完成的。
我有一个已捕获并需要处理的.bz2格式文件列表,有些文件丢失且没有数据,我需要在熊猫框架中将其对应的行留空。< / p>
例如,我有Sensor1,Sensor2,Sensor3。时间戳大于Sensor1的值。
我尝试附加到数据框时出现以下错误。
ValueError: Length of values does not match length of index
这是我处理文件的方式
hours_counter = 0
minutes_counter = 0
days_counter = 0
for j in range(90):
days_counter = days_counter + 1
if days_counter > 23:
days_counter = 0
for i in range(360):
minutes_counter = minutes_counter + 15
if minutes_counter == 45:
minutes_counter = 0
hours_counter = hours_counter + 1
s = datetime.strptime('2018-08-21', '%Y-%m-%d') + timedelta(hours=hours_counter, minutes=minutes_counter, days= days_counter)
timeStamps.append(s)
path = os.path.join(r'C:\\ahmed\\SpeedFT-meter1\\peakdata\\'+ s.strftime("%Y-%m-%d")+ r'\\peakdata_' + s.strftime("%Y%m%d_%H%M") + r'.bz2')
print(path)
directoary_names.append(path)
for idx in range(len(directoary_names)):
process_data(directoary_names[idx], i, directoary_names)
i = i + 1
写入到excel文件中,这只会导致传感器数据异常,时间戳是可以确定的
general_pd['TimeStamp'] = timeStamps
general_pd['C_strain_COY'] = S1
general_pd['C_strain_CUY'] = S3
general_pd['C_strain_ROX'] = S4
general_pd['C_strain_CUX'] = S5
general_pd['C_strain_CMX'] = S6
general_pd['C_strain_COX'] = S7
general_pd['C_temp_CUY'] = T1
general_pd['C_temp_COY'] = T2
general_pd['C_temp_CUX'] = T3
general_pd['C_temp_CMX'] = T4
general_pd['C_temp_COX'] = T5
writer = pd.ExcelWriter(r'c:\ahmed\median_data_meter_1.xlsx', engine='xlsxwriter')
# Convert the dataframe to an XlsxWriter Excel object.
general_pd.to_excel(writer, sheet_name='Sheet1')