I'm getting error "error: bad escape \d at position 1" when working on date formatting. I have to convert from format 11/13.2015 to 11/13/2015. I'm replacing using a regex and converting to a date-time format. Below is the code:
import pandas as pd
import datetime as dt
File = pd.read_excel("dotcharacter.xlsx")
Final_file = File["Date"].replace("[\d{2}\/\d{2}\.\d{4}]","[\d{2}\/\d{2}\/\d{4}]",regex=True)
Final_file["Date"] = pd.to_datetime(Final_file["Date"]).dt.strftime("%m/%d/%Y")
Final_file.to_excel("modified_file.xlsx")
Simple, File.replace(".","/")
will do the trick. However, how can I test using a regex? I'm new to Python. So, I am trying something different.