I am trying to convert a raw csv file that has a value of 12/31/99 in a column in pandas. I want to convert it to 12/31/2099. But my code converts it to 12/31/1999 instead.
If possible, I don't want to resort to hacks (like doing string manipulation and add 20 before the year number)
I am using these formatting placeholders: %m-%d-%y
Is there a way to control how %y is converted? Below shows a simple program that illustrates my conversion pseudocode to check how conversion works on 00-99 year. Basically, I want to control how it behaves 70+.
for _ in range(60 , 100, 10):
t = "03-01-{0}".format(str(_).zfill(2))
x = datetime.strptime(t, '%m-%d-%y')
print(t," ",x)
Example:
input :
03-01-60
03-01-70
03-01-80
03-01-90
output : (notice 1970, 1980, 1990)
03-01-60 2060-03-01 00:00:00
03-01-70 1970-03-01 00:00:00
03-01-80 1980-03-01 00:00:00
03-01-90 1990-03-01 00:00:00
expected output :
03-01-60 2060-03-01 00:00:00
03-01-70 2070-03-01 00:00:00
03-01-80 2080-03-01 00:00:00
03-01-90 2090-03-01 00:00:00