The date in my data does not come in one single format. It comes as "yyyy", "mm/dd/yyyy" and "Jun-03". I want to extract the year out of it.
Using dateutil:
In [24]: import dateutil.parser as parser
In [28]: parser.parse('Jun-03').year # assumes the current year
Out[28]: 2013
In [29]: parser.parse('08/09/2012').year
Out[29]: 2012
In [30]: parser.parse('2012').year
Out[30]: 2012
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With