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.
df['log'] = df.log.str.replace("^whats|what’s", "what is")?’smight be totally different thing which is just shown like this, hence if you copy it out as it is here, all works, but in your dataset the actual character is not’s. Your finding suggest that, for me it find the row with’s.