I have a data frame:
user_id url
111 google.com
111 youtube.com
111 youtube.com
111 google.com
111 stackoverflow.com
111 google.com
222 twitter.com
222 google.com
222 twitter.com
I want to create a column that will show the fact of visiting this URL before.
Desired output:
user_id url target
111 google.com 0
111 youtube.com 0
111 youtube.com 1
111 google.com 1
111 stackoverflow.com 0
111 google.com 1
222 twitter.com 0
222 google.com 0
222 twitter.com 1
I can do this with a loop but it doesn't look good. Is it possible to make it with pandas?