I'm having a problem replacing a part of the string in Pandas.
I have a list of links of a website like this (for example):
https://stackoverflow.com/questions
https://stackoverflow.com/some_page
https://stackoverflow.com/about
and I would like to replace https://stackoverflow.com/ with link/.
And it should be like this:
link/questions
link/some_page
link/about
I tried something like this but it replaces the whole string:
df.loc[df['links'].str.contains('https://stackoverflow.com/'), 'links'] = 'link/'
links is the name of column
How do I do this?
Thanks in advance.
https://stackoverflow.com/, or just for this example. If it is static, you can just replace it directly withstr.replace