In my dataset, I have a date column in which the data is of mixed format.
- Some rows only have
YYYY(e.g.2009) - Others have
MMM-YY(e.g.Jan-08) - Yet others have a full date
MM/DD/YYYY(e.g.01/15/2006)
How might I remove the entries that do not follow the format MM/DD/YYYY? I'm not quite sure where to start here.
Below, I have provided the .head() of the data as a dict.
{'Collection Date': {0: '2001',
1: '2002',
2: '2006',
3: '2/19/2006',
4: '2/28/2006'},
'Complete Genome': {0: 'No', 1: 'No', 2: 'No', 3: 'No', 4: 'No'},
'Country': {0: 'Egypt', 1: 'Egypt', 2: 'Egypt', 3: 'Egypt', 4: 'Egypt'},
'Flu Season': {0: '-N/A-', 1: '-N/A-', 2: '-N/A-', 3: '-N/A-', 4: '-N/A-'},
'Host Species': {0: 'IRD:Human',
1: 'IRD:Human',
2: 'IRD:Bird/Avian',
3: 'IRD:Chicken/Avian',
4: 'IRD:Avian'},
'Protein Name': {0: 'NA', 1: 'NA', 2: 'NA', 3: 'NA', 4: 'HA'},
'Segment': {0: 6, 1: 6, 2: 6, 3: 6, 4: 4},
'Segment Length': {0: 1428, 1: 1449, 2: 1441, 3: 1363, 4: 1707},
'Sequence Accession': {0: 'AJ457944',
1: 'AJ457943',
2: 'GU050304',
3: 'GQ184251',
4: 'KF178948'},
'State/Province': {0: '-N/A-',
1: '-N/A-',
2: '-N/A-',
3: '-N/A-',
4: '-N/A-'},
'Strain Name': {0: '(A/Egypt/84/2001(H1N2))',
1: '(A/Egypt/96/2002(H1N2))',
2: 'A/avian/Egypt/920431/2006(H9N2)',
3: 'A/chicken/Egypt/06207-NLQP/2006(H5N1)',
4: 'A/chicken/Egypt/0626/2006'},
'Subtype': {0: 'H1N2', 1: 'H1N2', 2: 'H9N2', 3: 'H5N1', 4: 'H5N1'}}
MM/DD/YYYY. Would that be possible? I will also modify the question.MM/DD/YYYY, in your case using string length is easier and simpler than a messy regexp string