python時戳轉換成字串日期,並形成時間序列檔案
阿新 • • 發佈:2019-01-11
######### Get all performance data of one object def get_one_object_perfor_data(object_id,dst_dir,src_file_name): df = pd.read_csv(src_file_name,delimiter=',',header=0) df_tmp1 = df[df['res_ins_id'] == object_id] i=0 df_tmp=df_tmp1.reset_index(drop=True)##index need to be reset from 0 to Nfor time_id in df_tmp['time_id']: d_time = dt.datetime.fromtimestamp(time_id/1000) #df_tmp['time_id'][i] = d_time.strftime("%Y-%m-%d %H:%M:%S.%f") df_tmp['time_id'][i] = d_time.strftime("%Y-%m-%d") i=i+1 df_tmp.to_csv(path_or_buf=os.path.join(dst_dir,str(object_id)+'.csv')) return0