2016-07-01 3 views
-1

나는 데이터 팬더 : str.contains와 조건()

url 
https://s.youtube.com/api/stats/qoe?fexp=9416891%2C9419451%2C9422596%2C9428269%2C9428398%2C9428492%2C9431012%2C9431657%2C9431674%2C9433096%2C9433380%2C9433946%2C9434803%2C9435467%2C9435526%2C9435876%2C9436275%2C9436302%2C9436484%2C9437553%2C9437967%2C9438327%2C9438699%2C9439362%2C9439652%2C9439816&afs=0.040%3A234%3B%3A%3Ai%2C30.155%3A233%3B%3A234%3Aa%2C60.039%3A234%3B%3A233%3Aa&cos=iOS&c=ios&cl=126064855&ei=7kB1V6PYKYSZWc7Do5AO&snd=0.003%3A0&feature=g-high&cver=11.23.9&conn=0.003%3A3&view=0.040%3A320%3A180%3A2%2C30.155%3A320%3A180%3A2%2C60.039%3A320%3A180%3A2&cmodel=iPhone5%2C1&fmt=229&ad_break_type=0&event=streamingstats&vnd=0.003%3A0&cbrver=11.23.9&vis=0.003%3A0&cosver=9.3.2&vps=0.000%3AN%2C9.468%3AB%2C9.474%3APL%2C15.020%3AB%2C30.180%3APL%2C175.020%3APA%2C238.456%3ASU&cbr=com.google.ios.youtube&bwe=0.040%3A773807&error=20.304%3Aios.cm.-12318%3A5.229%3Aec.cm.-12318%3Bshost.r1---sn-q0c7dn7z.googlevideo.com%2C24.163%3Aios.cm.-12889%3A5.230%3Aec.cm.-12889%3Bshost.r1---sn-q0c7dn7z.googlevideo.com%2C25.655%3Aios.cm.-12889%3A5.230%3Aec.cm.-12889%3Bshost.r1---sn-q0c7dn7z.googlevideo.com&bwm=30.157%3A842717%3A16.579%2C60.044%3A2638763%3A24.468%2C90.043%3A1351020%3A33.381%2C120.042%3A1658050%3A20.401%2C150.042%3A5393743%3A39.706%2C180.040%3A1093239%3A24.764&plid=AAU2gOYQwAPoGwuT&cnetwork=wifi&cplatform=mobile&vfs=0.040%3A230%3B%3A230%3A%3Ai%2C30.155%3A269%3B%3A230%3A230%3Aa%2C60.039%3A229%3B%3A230%3A269%3Aa&ns=yt&docid=QxsmWxxouIM&bat=0.006%3A0.61%3A0%2C157.152%3A0.60%3A0&bh=9.468%3A4.8%2C9.474%3A4.8%2C15.020%3A0.0%2C30.155%3A5.3%2C30.180%3A10.6%2C60.039%3A44.9&cpn=gl2S0rZF013jWHTp 
https://s.youtube.com/api/stats/qoe?cmodel=iPhone5%2C1&c=ios&ns=yt&bat=265.123%3A0.59%3A0&plid=AAU2gOYQwAPoGwuT&cplatform=mobile&cbrver=11.23.9&event=streamingstats&cos=iOS&fmt=229&vps=267.521%3ASU&cl=126064855&fexp=9416891%2C9419451%2C9422596%2C9428269%2C9428398%2C9428492%2C9431012%2C9431657%2C9431674%2C9433096%2C9433380%2C9433946%2C9434803%2C9435467%2C9435526%2C9435876%2C9436275%2C9436302%2C9436484%2C9437553%2C9437967%2C9438327%2C9438699%2C9439362%2C9439652%2C9439816&cnetwork=wifi&ad_break_type=0&cpn=gl2S0rZF013jWHTp&cosver=9.3.2&docid=QxsmWxxouIM&feature=g-high&cbr=com.google.ios.youtube&bwm=267.526%3A266451%3A2.419&ei=7kB1V6PYKYSZWc7Do5AO&cplayer=NATIVE_MEDIA_PLAYER&cver=11.23.9 
http://gsp1.apple.com/pep/gcc 

을하고 난 youtube를 포함하는 모든 문자열을 얻을 필요가있다. 시도해 봅니다.

df[df['url'].str.contains("youtube")] 

그러나 정확한 데이터 프레임을 반환하지 않으며 다른 데이터는 삭제하지 않습니다. 안양의 머리 :

size            url 
5663 316  http://captive.apple.com/hotspot-detect.html 
5670 606 http://counter.yadro.ru/hit?uhttp://m.vk.com/;... 
24453 316  http://captive.apple.com/hotspot-detect.html 
26818 569 https://www.googleadservices.com/pagead/conver... 
26821 597 https://s.youtube.com/api/stats/watchtime?fexp... 
26822 597 https://s.youtube.com/api/stats/qoe?fexp=94168... 

DTYPE

date  datetime64[ns] 
id     int64 
request   object 
browser   object 
version    int64 
type    object 
size    int64 
url    object 
dtype: object 
+0

유형을 시도'df.head()'과' –

+0

@Noobie이 – ldevyataykina

+0

보고 질문을 추가 df.dtypes' 내 업데이트 된 답변 –

답변

0

df[df['myurl']=df.url.to_string() 
df[df['myurl'].str.contains('youtube', case=False)] 
+0

그것은 또한 모든 URL을 반환합니다 – ldevyataykina

+0

'head (df)'의 출력을 보여줄 수 있습니까? – IanS

+0

@IanS 질문에 추가 – ldevyataykina