This question is similar to this one and I originally answered it with this solution but it turns out I misread the question. However, I feel my answer would be useful for a slightly different use case, and so I post it here.
Given a text file:
04/20/2009; 04/20/09; 4/20/09; 4/3/09
Mar-20-2009; Mar 20, 2009; March 20, 2009; Mar. 20, 2009; Mar 20 2009;
20 Mar 2009; 20 March 2009; 20 Mar. 2009; 20 March, 2009
Mar 20th, 2009; Mar 21st, 2009; Mar 22nd, 2009
Feb 2009; Sep 2009; Oct 2010
6/2008; 12/2009
2009; 2010
Containing already extracted dates in varying formats... the task is to read them into a data frame and then sort them, and then display the output in MM/DD/YYYY format.
Expected output:
0 06/01/2008
1 01/01/2009
2 02/01/2009
3 03/20/2009
4 03/20/2009
5 03/20/2009
6 03/20/2009
7 03/20/2009
8 03/20/2009
9 03/20/2009
10 03/20/2009
11 03/20/2009
12 03/20/2009
13 03/21/2009
14 03/22/2009
15 04/03/2009
16 04/20/2009
17 04/20/2009
18 04/20/2009
19 09/01/2009
20 12/01/2009
21 01/01/2010
22 10/01/2010
How can this be done in pandas?
Note: If the day is missing, consider the 1st and if the month is missing consider January.