0

I have data

                                          event_address           event_time  
0      https://mail.yandex.ru/clck=2230&uid=1189231...  2016-06-14 03:05:19   
1      https://mail.yandex.ru/?ncrnd=2230&uid=1189231...  2016-06-14 03:05:23   
2      https://mail.yandex.ru/clck=2230&uid=1189231...  2016-06-14 03:05:24   
3        http://mail.yandex.ru/?win=219&clid=2257587-216  2016-06-14 03:04:52   
4       https://mail.yandex.ru/?win=219&clid=2257587-216  2016-06-14 03:04:52   
5                     https://mail.yandex.ru/?ncrnd=2230  2016-06-14 03:05:12   
6      https://mail.yandex.ru/?ncrnd=2230&uid=1189231...  2016-06-14 03:05:25   

I want to delete str, where url contain yandex.ru/clck. Desire output

                                          event_address           event_time    
1      https://mail.yandex.ru/?ncrnd=2230&uid=1189231...  2016-06-14 03:05:23      
3        http://mail.yandex.ru/?win=219&clid=2257587-216  2016-06-14 03:04:52   
4       https://mail.yandex.ru/?win=219&clid=2257587-216  2016-06-14 03:04:52   
5                     https://mail.yandex.ru/?ncrnd=2230  2016-06-14 03:05:12   
6      https://mail.yandex.ru/?ncrnd=2230&uid=1189231...  2016-06-14 03:05:25  

I try use ~df[df.event_address.str.contains("yandex.ru/clck")]but it return

TypeError: bad operand type for unary ~: 'unicode'

2

1 Answer 1

2

try this:

df[~df.event_address.str.contains(r"yandex.ru/clck")]

demo:

In [167]: df[~df.event_address.str.contains(r"yandex.ru/clck")]
Out[167]:
                                      event_address
1    https://mail.yandex.ru/?ncrnd=2230&uid=1189231
3   http://mail.yandex.ru/?win=219&clid=2257587-216
4  https://mail.yandex.ru/?win=219&clid=2257587-216
5                https://mail.yandex.ru/?ncrnd=2230
6    https://mail.yandex.ru/?ncrnd=2230&uid=1189231

In [168]: df
Out[168]:
                                      event_address
0      https://mail.yandex.ru/clck=2230&uid=1189231
1    https://mail.yandex.ru/?ncrnd=2230&uid=1189231
2      https://mail.yandex.ru/clck=2230&uid=1189231
3   http://mail.yandex.ru/?win=219&clid=2257587-216
4  https://mail.yandex.ru/?win=219&clid=2257587-216
5                https://mail.yandex.ru/?ncrnd=2230
6    https://mail.yandex.ru/?ncrnd=2230&uid=1189231
Sign up to request clarification or add additional context in comments.

3 Comments

@ldevyataykina, yes, it does - see the demo in my answer
I loved these comments! @Idevyataykina don't forget to accept the answer :)
@ysearka, sometimes, When the correct answer is ready, I can't do it, because It should take about 20 minutes after answer. Acception is done)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.