我有这样的数据框: Flt Desg Eff Date Dis Date day of week Routing0 AI 0922 8-May 8-May ....fri,.. riyadh-calicut1 AI 0381 8-May 12-May .tue,..fri,.. singapore-delhi2 AI 1242 8-May 13-May .tue,wed,.fri,.. dhaka-srinagar3 AI 0130 9-May 9-May .....sat,. london-mumbai4 AI 0174 9-May 9-May .....sat,. san francisco-mumbai.. ... ... ... ... ...615 AI 1932 25-Jul 25-Jul .....sat,. jeddah-delhi616 AI 1936 25-Jul 25-Jul .....sat,. borispill-delhi617 AI 1938 25-Jul 25-Jul .....sat,. manas-srinagar-delhi618 AI 1942 25-Jul 25-Jul .....sat,. dammam-bengaluru619 AI 1954 25-Jul 25-Jul .....sat,. doha-mumbai-vijayawada[620 rows x 5 columns]我想根据从开始的路由提取 Flt、Desg、Eff Date、Dis Date、星期几的数据moscow
1 回答
一只萌萌小番薯
TA贡献1795条经验 获得超7个赞
DataFrame.loc
与以下一起使用Series.str.startswith
:
cols = ['Flt', 'Desg', 'Eff Date', 'Dis Date', 'day of week'] df1 = df.loc[df['Routing'].str.startswith('moscow'), cols]
如果需要所有列:
df2 = df[df['Routing'].str.startswith('moscow')]
添加回答
举报
0/150
提交
取消