JAB JAB - 1 year ago 70
Python Question

Format pandas datatime object to show fiscal years from Feb to Feb and be formatted as %Y?

I have a series of timestamps like so,

3 2013-08-23 00:00:00
4 2008-09-21 00:00:00
5 2012-03-17 00:00:00
6 2011-12-31 00:00:00
7 2011-11-16 00:00:00
8 2008-01-23 00:00:00
9 2010-06-13 00:00:00

I want to convert them to Fiscal Years in the format 2010, 2011 etc. The fiscal Year runs FEB-JAN.
I am confused- do I need to use offset? How do I change the represention from a timestamp to just the fiscal year portion?

Thank you.

Answer Source

I found an answer. Unlikely to be the best one or if so that's serendipity for you.

 df['DATE']=pd.to_datetime(df.DATE).apply(pd.Period, freq='A-FEB')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download