1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- from math import radians, cos, sin, asin, sqrt
- import pandas as pd
- import numpy as np
- from datetime import datetime
- from datetime import timedelta
- from GpsRank import *
- from ProcessDfBms import *
- from ProcessDfGps import *
- from CalDist import *
- from LIB.BACKEND import DBManager
- import pdb
- asset_table_path='D:\\work\\Qixiang\\data_analyze_platform\\pengmin\\AllCarDist\\asset_table.xlsx'
- drive_info_path='D:\\work\\Qixiang\\data_analyze_platform\\pengmin\\AllCarDist\\drive_info.xlsx'
- asset_sheet_num=1
- usecols_list=[4,5]
- asset_table=pd.read_excel(asset_table_path,sheet_name=asset_sheet_num,skiprows=1,usecols=usecols_list)
- SN_list=asset_table['SN号'].values.tolist()
- print('从6060sheet读取到:'+str(len(SN_list))+'行')
- asset_table=asset_table.rename(columns={'SN号':'SN','状态':'state'})
- asset_table.set_index(["SN"],inplace=True)
- col_name=asset_table.columns.tolist()
- col_name.extend(['range','accum_soc','day_start_soc','day_end_soc','day_start_time','day_end_time'])
- asset_table=asset_table.reindex(columns=col_name)
- start_hour='00:00:00'#每日查询最早时间
- end_hour='23:59:00'#每日查询最晚时间
- date_index=pd.date_range('2021-07-31','2021-07-31')
- for date in date_index:
- '''遍历日期'''
- str_date=str(date)[:10]
- input_starttime=str_date+' '+start_hour
- input_endtime=str_date+' '+end_hour
- test_day=str_date[5:10]#月-日,用于建立sheet
- drive_info_path='D:\\work\\Qixiang\\data_analyze_platform\\pengmin\\AllCarDist\\6060\\drive_info'+test_day+'_50_end_'+'.xlsx'
- print(input_starttime)
- drive_info_aday=pd.DataFrame()
- SN_list_short=SN_list#先选择了0:50,50:end
- for SN in SN_list_short:
- '''遍历SN号'''
- SN=SN.strip('\t')
- SN=SN.strip('\n')
- try:
- range=GetDistInfo(SN,input_starttime,input_endtime)
- range_df=pd.DataFrame([range])
- drive_info_aday=pd.concat([drive_info_aday,range_df],axis=0)
- except:
- print(SN+' '+test_day+'fail')
- else:
- pass
- #print(SN+' '+test_day+'success')
- drive_info_aday.to_excel(drive_info_path,sheet_name=test_day)#sheet名称为testday
-
-
|