I have the following pandas dataframe. Say it has 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 that the dataset above is unaffected, but I get in return for this dataset:
id search_term
37651 in. in. switch
which means inl
is replaced by in.
and ine
is replaced by in.
, as if I where using a regular expression, where dot means any character.
How do I rewrite the first command so that, literally, in.
is replaced by in.
but any in
not followed by a dot is untouched, as in:
a = 'inline switch'
a = a.replace('in.','in. ')
a
>>> 'inline switch'