Reputation: 73
I have a Pandas column with the path of some pictures like this:
http://localhost:8888/view/Desktop/directory1/directory2/john.jpeg
http://localhost:8888/view/Desktop/directory1/directory2/alice.jpeg
http://localhost:8888/view/Desktop/directory1/directory2/joseph.jpeg
...
I need to replace /view/
for /files/
. Wichi Pandas method do I have to use to iterate and doing it?
Upvotes: 0
Views: 197
Reputation:
Use .str.replace
:
df['YOUR COLUMN'] = df['YOUR COLUMN'].str.replace('/files/', '/views/')
Output:
YOUR COLUMN
0 http://localhost:8888/files/Desktop/directory1/directory2/john.jpeg
1 http://localhost:8888/files/Desktop/directory1/directory2/alice.jpeg
2 http://localhost:8888/files/Desktop/directory1/directory2/joseph.jpeg
Upvotes: 1