I have a data frame with df['text'].
A sample value of df['text'] could be:
"The quick red.fox jumped over.the lazy brown, dog."
I want the output to be:
"The quick red . fox jumped over . the lazy brown , dog . "
I've tried using the str.replace() method, but I don't quite understand how to make it do what I'm looking for.
import pandas as pd
# read csv into dataframe
df=pd.read_csv('./data.csv')
#add a space before and after every punctuation
df['text'] = df['text'].str.replace('.',' . ')
df['text'].head()
# write dataframe to csv
df.to_csv('data.csv', index=False)