- I've problem with replacing, here's what I wrote, I need to replace 1999 with 1900 as you can see. I started recently, so please excuse me. (I searched a lot and watched clips on YouTube, but the method didn't work.)
import pandas as pd
df = pd.read_excel('book1.xlsx')
#replace
df.replace("1999","1900")
#I also tried this method, but it didn't work.
#df.replace(to_replace = "1999", value = "1900")
#writer
writer = pd.ExcelWriter('book2.xlsx')
df.to_excel(writer,'new_sheet')
writer.save()
- My second question, how can I replace data through a text file (or Excel), for example, replace 1999 (in column A, book1.xlsx) with the column b in mistakes.xlsx.
A B
1999 1900
Thank you guys for the help.