Pandas 如何查找同一财政年度的日期?

Pandas 如何查找同一财政年度的日期?,pandas,Pandas,我的数据框看起来像这样 ECSDate DateOfTransfer Amount 2011-12-04 2011-05-16 25000 2012-11-10 2011-05-16 3000 2013-02-19 2011-05-21 13750 我需要确定ECS和转账日期是否在从4月1日开始到3月31日结束的同一财政年度 If Month is Jan, Feb or march then: 2013-02-19 - 1 year = 2012-02-19

我的数据框看起来像这样

ECSDate DateOfTransfer  Amount
2011-12-04      2011-05-16 25000
2012-11-10      2011-05-16 3000
2013-02-19      2011-05-21 13750
我需要确定ECS和转账日期是否在从4月1日开始到3月31日结束的同一财政年度

If Month is Jan, Feb or march then:
2013-02-19 - 1 year = 2012-02-19 and 2012-04-01 is greater than 2011-05-21 so false

Else:
2012-11-10 start of year is 2012-04-01 and greater than 2011-05-16 so false
预期结果将是

True
False
False

编辑:

我试过的东西

这是一年前的日期:

mydf['NEW_DATE'] = mydf['ECSDate'].apply(lambda x: x - pd.DateOffset(years=1))
比较一下:

pd.to_datetime(mydf['NEW_DATE'].dt.year, 04, 01) < DateOfTransfer   
pd.Period('2011-12-04', freq='A-MAR') == pd.Period('2011-05-16', freq='A-MAR')

pd.Period('2012-11-10', freq='A-MAR') == pd.Period('2011-05-16', freq='A-MAR')

pd.Period('2013-02-19', freq='A-MAR') == pd.Period('2011-05-21', freq='A-MAR')
mydf[mydf['ECSDate'].dt.to_period(freq='A-MAR') == mydf['DateOfTransfer'].dt.to_period(freq='A-MAR')]