代码拉取完成,页面将自动刷新
同步操作将从 radcircle/pandasBaiduapi 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import pandas as pd
from sqlalchemy import create_engine
engine = create_engine('mysql+pymysql://root:123@localhost/baidutraffice')
df = pd.read_sql('select * from journeys', engine)
df1 = df[((df['journey_number'] == df['journey_number'].shift(1))
& (df['route_number'] == df['route_number'].shift(1)))
| ((df['journey_number'] == df['journey_number'].shift(-1)) &
(df['route_number'] == df['route_number'].shift(-1)))]
df2 = df[((df['route_number'] != df['route_number'].shift(1))
& (df['route_number'] != df['route_number'].shift(-1)))
]
df3 = df1[df1['route_number'] == df1['route_number'].shift(-1)]
df3['The_duration'] = df1[df1['route_number'].shift(-1) == df1['route_number']].loc['The_duration'] = df1['The_duration'] + df1['The_duration'].shift(-1)
df3['vehicle_name'] = df1[df1['route_number'].shift(-1) == df1['route_number']].loc['vehicle_name'] = df1[
'vehicle_name'] + ',' + df1['vehicle_name'].shift( -1)
df3['arrive_station_name'] = df1[df1['route_number'].shift(-1) == df1['route_number']].loc['arrive_station_name'] = df1[
'arrive_station_name'].shift(-1)
df3['arrive_time'] = df1[df1['route_number'].shift(-1) == df1['route_number']].loc['arrive_time'] = df1[
'arrive_time'].shift(-1)
DF = pd.concat([df2, df3])
DF.to_sql(name='journeys_modify', con=engine, if_exists='replace', index=False)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。