I have a dataframe, which shows som text in one column and the language of the text in another column. Instead of having 'en', 'ru' etc. written in the language column, I have tried to turn these abbreviations into full words:
df['text'] = df['text'] \
.str.replace('en', 'English') \
.str.replace('ru', 'Russian') \
.str.replace('fr', 'French') \
.str.replace('tr', 'Turkish') \
.str.replace('es', 'Spanish')
# The number of languages goes on..
The issue, however, is that it finds 'en', for example, in other words (such as French), which doesn't give the best output, when I run the dataframe:
English 959874
Russian 419963
FrEnglishch 93797
Turkish 87225
Spanish 74120
PortuguSpanisHebrew 31627
# And so on..
How can I avoid that it searches for 'en', for instance, in all words and not only, when 'en' stands alone in a column?