I need to replace the specific values in every row of pandas df with another value. My data looks like this:
time log
1 whats the weather look like today
2 what is the weather look like today
3 whats for lunch
4 what’s for lunch
I need to replace whats
to be what is
and what’s
to be what is
also.
The desired output:
time log
1 what is the weather look like today
2 what is the weather look like today
3 what is for lunch
4 what is for lunch
I have tried:
new_df = df.log.str.replace("^whats", "what is").str.replace("^what’s", "what is")
This took care of whats
but not the other case and the outcome is not a pandas df and I need it to be pandas df.