我的Dataframe看起来像这样......
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
编辑:
我试过的东西。
这是1岁的日期:
mydf['NEW_DATE'] = mydf['ECSDate'].apply(lambda x: x - pd.DateOffset(years=1))
比较它:
pd.to_datetime(mydf['NEW_DATE'].dt.year, 04, 01) < DateOfTransfer
编辑:
以下语句正确返回True,False值。但是如何将其应用于数据框?
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')
答案 0 :(得分:0)
bytes, err := Marshal(input, options...)