# distinguish peak-hours and nopeak_hours
# coding:utf-8
import pandas as pd
df=pd.read_csv('F://cxx//the_last_check//odt_rank//odt_rank1o_164d_8562.csv')
week_mpeak,weekendmpeak,week_npeak,weekendnpeak,week_nomal,weekend_nomal=pd.DataFrame({'Unnamed':'','cellid':'','stime':'','etime':'','traveltime':'','origion':'','destination':''},index=['0']),pd.DataFrame({'Unnamed':'','cellid':'','stime':'','etime':'','traveltime':'','origion':'','destination':''},index=['0']),pd.DataFrame({'Unnamed':'','cellid':'','stime':'','etime':'','traveltime':'','origion':'','destination':''},index=['0']),pd.DataFrame({'Unnamed':'','cellid':'','stime':'','etime':'','traveltime':'','origion':'','destination':''},index=['0']),pd.DataFrame({'Unnamed':'','cellid':'','stime':'','etime':'','traveltime':'','origion':'','destination':''},index=['0']),pd.DataFrame({'Unnamed':'','cellid':'','stime':'','etime':'','traveltime':'','origion':'','destination':''},index=['0'])
for i in range(len(df)):
if ((int(str(df['stime'][i])[5:8]) >= 504) & (int(str(df['stime'][i])[5:8]) <= 508)) | (
(int(str(df['stime'][i])[5:8]) >= 511) & (int(str(df['stime'][i])[5:8]) <= 515)): # 判断是工作日
if (int(str(df['stime'][i])[8:10]) >= 7) & (int(str(df['stime'][i])[8:10]) <= 9): # 判断是早高峰
line=df[i:i+1]
week_mpeak = week_mpeak.append(line, ignore_index=True)
elif (int(str(df['stime'][i])[8:10]) >= 17) & (int(str(df['stime'][i])[8:10]) <= 19): # 判断是晚高峰
line = df[i:i + 1]
week_npeak = week_npeak.append(line, ignore_index=True)
else:
line = df[i:i + 1]
week_nomal = week_nomal.append(line, ignore_index=True)
else:
if (int(str(df['stime'][i])[8:10]) >= 7) & (int(str(df['stime'][i])[8:10]) <= 9): # 判断是早高峰
line=df[i:i+1]
weekendmpeak = weekendmpeak.append(line, ignore_index=True)
elif (int(str(df['stime'][i])[8:10]) >= 17) & (int(str(df['stime'][i])[8:10]) <= 19): # 判断是晚高峰
line = df[i:i + 1]
weekendnpeak = weekendnpeak.append(line, ignore_index=True)
else:
line = df[i:i + 1]
weekend_nomal = weekend_nomal.append(line, ignore_index=True)
week_mpeak.to_csv('F://cxx//the_last_check//odt_rank//164_8562//week_mpeak.csv')
week_npeak.to_csv('F://cxx//the_last_check//odt_rank//164_8562//week_npeak.csv')
week_nomal.to_csv('F://cxx//the_last_check//odt_rank//164_8562//week_nomal.csv')
weekendmpeak.to_csv('F://cxx//the_last_check//odt_rank//164_8562//weekend_mpeak.csv')
weekendnpeak.to_csv('F://cxx//the_last_check//odt_rank//164_8562//weekend_npeak.csv')
weekend_nomal.to_csv('F://cxx//the_last_check//odt_rank//164_8562//weekend_nomal.csv')