參考這個解決:https://www.5axxw.com/questions/content/gzoq3q
具體代碼
sqlLongSss="SELECT * FROM table1 ;"
df=pd.read_sql(sqlLongSss,con=con)
tt1="0713"#一陣日期亂倒
tt2=datetime.datetime.strptime(tt1, '%H%M').strftime('%H:%M:%S')#P轉time F轉字符串
tt3=datetime.datetime.strptime(tt2,'%H:%M:%S')
tt4=tt3+datetime.timedelta(minutes=10)
tt5=tt4.strftime('%H:%M:%S')
threshold = pd.Timedelta(tt5)
print(threshold)
df['LastTimeHHMM']=pd.to_datetime(df['LastTime']).dt.time
df['Total Time'] = pd.to_timedelta(pd.to_datetime(df['LastupateTimeHHMM'].astype(str)).dt.strftime('%H:%M:%S'))
df_styled = df[ df['Total Time'].apply(lambda x:x > threshold) ]