I have data in a csv file with dates stored as strings in a standard UK format - %d/%m/%Y
- meaning they look like:
12/01/2012
30/01/2012
The examples above represent 12 January 2012 and 30 January 2012.
When I import this data with pandas version 0.11.0 I applied the following transformation:
import pandas as pd
...
cpts.Date = cpts.Date.apply(pd.to_datetime)
but it converted dates inconsistently. To use my existing example, 12/01/2012 would convert as a datetime object representing 1 December 2012 but 30/01/2012 converts as 30 January 2012, which is what I want.
After looking at this question I tried:
cpts.Date = cpts.Date.apply(pd.to_datetime, format='%d/%m/%Y')
but the results are exactly the same. The source code suggests I'm doing things right so I'm at a loss. Does anyone know what I'm doing wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…