I have the following pandas framework. for simplicity, suppose it has only two columns: id and search_term
id search_term 37651 inline switch
I do:
train['search_term'] = train['search_term'].str.replace("in."," in. ")
expecting the dataset above will not be affected, but I get this dataset in return:
id search_term 37651 in. in. switch
which means that inl is replaced by in. , and ine is replaced by in. as if I were using a regex, where dot means any character.
How to transfer the first command so that literally in. has been replaced by in. , but any in followed by a period is not touched, as in:
a = 'inline switch' a = a.replace('in.','in. ') a >>> 'inline switch'
source share