''' 基于某个周期(一天,一周...)的指标统计库 ''' __author__ = 'Wang Liming' import CONFIGURE.PathSetting as PathSetting import sys sys.path.append(PathSetting.backend_path) sys.path.append(PathSetting.middle_path) import datetime import Tools import pandas as pd import numpy as np import IndexStaByOneCycle class IndexStaByPeriod(): def __init__(self): self.indexStaByOneCycle = IndexStaByOneCycle.IndexStaByOneCycle() pass def drive_odo_sta(self, df_bms, df_gps): ''' 计算周期内行车累积行驶里程 ---------输入参数------------ df_bms : 一段周期内的预处理后的bms数据 df_gps : 一段周期内的预处理后的gps数据 ---------输出参数------------ sum_odo : 累积里程, 如果该周期内gps均无效,则返回None invalid_rate : 该周期内gps无效的bms数据行所占比例 ''' invalid_count = 0 total_count = 0 sum_odo = 0 data_number_list = sorted(list(set(df_bms[(df_bms['data_status'].isin(['drive']))]['data_split_by_status_after_combine']))) if len(data_number_list) == 0: return {'sum_odo':0, 'invalid_rate':0} for data_number in data_number_list[:]: df_sel_bms = df_bms[df_bms['data_split_by_status_after_combine'] == data_number] df_sel_bms = df_sel_bms.reset_index(drop=True) total_count += len(df_sel_bms) if df_sel_bms.loc[0, 'gps_rely'] != 1: invalid_count += len(df_sel_bms) continue else: df_sel_gps = df_gps[(df_gps['时间戳']>df_sel_bms.loc[0,'时间戳']) & (df_gps['时间戳']