2 Commits f24aa786f7 ... f5e9b82c20

Author SHA1 Message Date
  zhuxi f5e9b82c20 main 2 years ago
  zhuxi dc0507bca2 3 models 2 years ago

BIN
LIB/MIDDLE/InfoChrgDrive/Charge/kmeans1.pkl


BIN
LIB/MIDDLE/InfoChrgDrive/Charge/kmeans2.pkl


BIN
LIB/MIDDLE/InfoChrgDrive/Charge/kmeans3.pkl


+ 4 - 1
LIB/MIDDLE/InfoChrgDrive/Charge/main_V0.py

@@ -72,7 +72,10 @@ def diag_cal():
                     df_diag_ram_sn=df_diag_ram[df_diag_ram['sn']==sn]
                     if not df_diag_ram_sn.empty:   #该sn相关结果非空
                         df_diag_ram_sn.reset_index(inplace=True,drop=True)
+                        df_diag_ram_sn['time_end']=list(map(lambda x: datetime.datetime.strptime(x,'%Y-%m-%d %H:%M:%S'),list(df_diag_ram_sn['time_end'])))
+                        df_diag_ram_sn = df_diag_ram_sn.sort_values(by = 'time_end')
                         df_diag_ram_sn=df_diag_ram_sn.iloc[-1]
+                        time_end =df_diag_ram_sn['time_end']
                         df_diag_ram_sn.reset_index(inplace=True,drop=True)
                 df_diag_new,df_diag_change=pro_output(df_merge,sn,gpscity,df_diag_ram_sn)
                 kmeans1 = joblib.load('kmeans1.pkl')
@@ -81,7 +84,7 @@ def diag_cal():
                 df_diag_new=prediction(df_diag_new,kmeans1,kmeans2,kmeans3)
                 df_diag_change=prediction(df_diag_change,kmeans1,kmeans2,kmeans3)
                 if not df_diag_change.empty:   #需变更的结果非空
-                    cursor.execute("DELETE FROM algo_charge_info WHERE time_end = '0000-00-00 00:00:00' and sn='{}'".format(sn))
+                    cursor.execute("DELETE FROM algo_charge_info WHERE time_end = '{}' and sn='{}'".format(time_end,sn))
                     mysql.commit()
                     df_diag_change.to_sql("algo_charge_info",con=db_res_engine, if_exists="append",index=False)